Named parameters in Rust
Posted 金庆
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Named parameters in Rust相关的知识,希望对你有一定的参考价值。
Named parameters in Rust
(Jin Qing’s Column, Nov. 18, 2021)
There is no “named function parameters” in Rust,
but there is an idiom for this case.
If a function needs many parameters, we can define a type
with all these parameters as fields, and implement Default
trait for this type.
Then we can input this type as the function parameter,
with some of the fields specified and others using default.
foo(Config
a: 123,
b: bool,
...Default::default(),
);
以上是关于Named parameters in Rust的主要内容,如果未能解决你的问题,请参考以下文章
Mybatis异常There is no getter for property named 'XXX' in 'class java.lang.String'(示例代
Pytorch children()modules()named_children()named_modules()named_parameters()parameters()使用说明
Pytorch children()modules()named_children()named_modules()named_parameters()parameters()使用说明
Pytorch中的model.named_parameters()和model.parameters()