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
use std::cell::{RefCell,RefMut};traitFooTrait{fnfootrait(&mutself);}structFoo;implFooTraitforFoo{fnfootrait(&mutself){()}}impl<'a>FooTraitforRefMut<'a,Foo>{fnfootrait(&mutself){()}}structBar{bar:RefCell<Foo>,}implBar{fnfoobox(&self) -> Box<FooTrait>{let inner = self.bar.borrow_mut();Box::new(inner)}}
I get the following (confusing) error message:
<anon>:21:30: 21:42 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
<anon>:21 let inner = self.bar.borrow_mut();
^~~~~~~~~~~~
<anon>:21:21: 21:29 note: first, the lifetime cannot outlive the expression at 21:20...
<anon>:21 let inner = self.bar.borrow_mut();
^~~~~~~~
<anon>:21:21: 21:29 note: ...so that auto-reference is valid at the time of borrow
<anon>:21 let inner = self.bar.borrow_mut();
^~~~~~~~
<anon>:21:21: 21:42 note: but, the lifetime must be valid for the method call at 21:20...
<anon>:21 let inner = self.bar.borrow_mut();
^~~~~~~~~~~~~~~~~~~~~
<anon>:21:21: 21:29 note: ...so that method receiver is valid for the method call
<anon>:21 let inner = self.bar.borrow_mut();
^~~~~~~~
After a lot of trial-and-error I noticed I had to do the following change:
When compiling the following code:
I get the following (confusing) error message:
After a lot of trial-and-error I noticed I had to do the following change:
The text was updated successfully, but these errors were encountered: