Reputation: 11
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
Upvotes: 1
Views: 237
Reputation: 58735
No, Rust doesn't have anything like this. You can generate getters using a macro, if you want to save typing.
Upvotes: 1