You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structFoo{s:String,s2:String,}implFoo{fnbar(self:Box<Self>){let f = *self;let _a = f.s;let _b = f.s2;}}fnmain(){let f = Foo{s:"hi".to_owned(),s2:"bye".to_owned()};Box::new(f).bar();}
This does not:
structFoo{s:String,s2:String,}implFoo{fnbar(self:Box<Self>){letFoo{ s, s2 } = *self;}}fnmain(){let f = Foo{s:"hi".to_owned(),s2:"bye".to_owned()};Box::new(f).bar();}
Due to this error:
<anon>:8:22: 8:24 error: use of moved value: `self` [E0382]
<anon>:8 let Foo { s, s2 } = *self;
^~
<anon>:8:22: 8:24 help: see the detailed explanation for E0382
<anon>:8:19: 8:20 note: `self` moved here (through moving `self.s`) because it has type `collections::string::String`, which is moved by default
<anon>:8 let Foo { s, s2 } = *self;
^
<anon>:8:19: 8:20 help: if you would like to borrow the value instead, use a `ref` binding as shown:
<anon>: let Foo { ref s, s2 } = *self;
error: aborting due to previous error
playpen: application terminated with error code 101
I don't understand why one form is legal and the other is not, and the error message does not make it clear to me.
The text was updated successfully, but these errors were encountered:
This compiles:
This does not:
Due to this error:
I don't understand why one form is legal and the other is not, and the error message does not make it clear to me.
The text was updated successfully, but these errors were encountered: