Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Foo(u32);
- impl Foo {
- // Currently have to write this:
- fn bar(self) {
- let Foo(inner) = self;
- }
- // Would prefer to write (something like) this:
- fn baz(Self(inner)) {
- // However, as it currently is, this is an associated function - not a method.
- }
- }
- fn main() {
- let x = Foo(4);
- x.bar();
- // Because baz is an associated method we cannot write:
- x.baz();
- }
- // Is what's in 'bar' currently the best way of unwrapping wrapped values?
- // Or is there some alternative akin to 'baz'?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement