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::borrow::BorrowMut;pubtraitValue{fnget(&self) -> i32;fnset(&mutself,value:i32);}pubstructUnmanagedValue{value:i32,}implValueforUnmanagedValue{fnget(&self) -> i32{self.value}fnset(&mutself,value:i32){self.value = value;}}pubstructManagedValue{value:i32,}implValueforManagedValue{fnget(&self) -> i32{self.value}fnset(&mutself,value:i32){ifself.value == value {return;}self.value = value;}}pubstructSetValueAction{value:i32,}pubtraitAction<T>:Sized{fnexecute(self,target:&mutT);}impl<V:Value,T:BorrowMut<V>>Action<T>forSetValueAction{fnexecute(self,target:&mutT){
target.borrow_mut().set(self.value);}}fnmain(){}
fails with error:
<anon>:47:6: 47:7 error: the type parameter `V` is not constrained by the impl trait, self type, or predicates [E0207]
<anon>:47 impl<V: Value, T: BorrowMut<V>> Action<T> for SetValueAction {
^
<anon>:47:6: 47:7 help: see the detailed explanation for E0207
error: aborting due to previous error
playpen: application terminated with error code 101
This is as per rust-lang/rfcs#447. <Action<Whatever> as SetValueAction>::execute must refer to a single method, but there can easily be multiple types that implement Value and are valid for BorrowMut.
fails with error:
But this function compiles
The text was updated successfully, but these errors were encountered: