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
Fairly self explanatory but it could be a partial solution to #2393 before it is implemented in the rust compiler
Suppose you have some code
use std::ops::Deref;traitFoo{fnfoo(&self);}structBar{}implFooforBar{fnfoo(&self){}}fnbaz<T:Foo>(_:&T){}structWrapBar{wbar:Bar}implDerefforWrapBar{typeTarget = Bar;fnderef(&self) -> &Self::Target{&self.wbar}}fnmain(){let b = WrapBar{wbar:Bar{}};// explicit call via &Bar&b.wbar.foo();// implicit Deref to &Bar before call, hooray https://doc.rust-lang.org/reference/expressions/method-call-expr.html&b.foo();// succeeds because WrapBar can be Deref'd to Bar because we are aware of baz::<Bar> having the signature &Bar -> ()baz::<Bar>(&b);// fails because WrapBar does not implement Foo because baz has signature &(T: Foo) -> ()// baz(&b);}
Maybe we can amend #241 so that the compiler tries Deref coercion for function arguments with unsolved traits as well.
If this is a dumb idea then feel free to just close this.
The text was updated successfully, but these errors were encountered:
Fairly self explanatory but it could be a partial solution to #2393 before it is implemented in the rust compiler
Suppose you have some code
Maybe we can amend #241 so that the compiler tries
Deref
coercion for function arguments with unsolved traits as well.If this is a dumb idea then feel free to just close this.
The text was updated successfully, but these errors were encountered: