Is there a way to replace in a "getter" method the return type
pub struct Foo {
key: MyKey,
value: usize,
}
impl Foo {
pub fn value(&self) -> usize {
...
}
}
by something like:
pub fn value(&self) -> Typeof(Self.value) { ... }
Thanks
No, Rust doesn't have anything like this. You can generate getters using a macro, if you want to save typing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.