Closed
Description
I think that adding a derive macro similar to CopyGetters
but for Clone
would be useful when working with reference counters.
Consider the struct:
struct Foo {
bar: Arc<u32>
}
I often find myself writing getters like this:
fn bar(&self) -> Arc<u32> {
Arc::clone(&self.bar)
}
that return owned Arc
s. However, this is not currently possible (it think) in getset
. You can't use CopyGetters
since Arc
isn't Copy
and you can't use Getters
since it would return a &Arc<...>
.
I think it can be left up to the user to decide whether cloning the type is "cheap", so it shouldn't be restricted to reference counters although I see this as the main use case.