SHARE
TWEET

Untitled

a guest Apr 19th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Foo(u32);
  2.  
  3. impl Foo {
  4.     // Currently have to write this:
  5.     fn bar(self) {
  6.         let Foo(inner) = self;
  7.     }
  8.     // Would prefer to write (something like) this:
  9.     fn baz(Self(inner)) {
  10.         // However, as it currently is, this is an associated function - not a method.
  11.     }
  12. }
  13.  
  14. fn main() {
  15.     let x = Foo(4);
  16.     x.bar();
  17.     // Because baz is an associated method we cannot write:
  18.     x.baz();
  19. }
  20.  
  21. // Is what's in 'bar' currently the best way of unwrapping wrapped values?
  22. // Or is there some alternative akin to 'baz'?
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top