ahh
-
-
Replying to @steveklabnik @sgrif
yeah it makes more sense when you realise it's invoking a function of two arguments, and Deref doesn't mean that fn will try to find a common deref target to make the type system happy
1 reply 0 retweets 3 likes -
Replying to @mountain_ghosts @steveklabnik
Nah, it can pick one. It's just because traits are involved (and there are multiple deref targets to choose from, though it could just pick the first in the chain tbh) https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=00257fc8db0914a33c6e000a038111e8 …
2 replies 0 retweets 2 likes -
basically, http://foo.bar () - style autoderef works in generic situations, but the kind of autoderef where &*** is automatically applied to things to coerce them is far more limited: if it's generic (or even if relying too heavily on inference) it won't work
1 reply 0 retweets 0 likes -
Yup, which is kinda silly because the same rules used to decide which type is the receiver of `.bar` can be applied whenever `&` is used for argument passing
1 reply 0 retweets 1 like -
not really: in the former situation you're looking for a type -- any type -- with the method "bar". it's a simple linear search down the deref chain in the latter you're looking for a type which satisfies certain constraints, which is much trickier
3 replies 0 retweets 1 like -
Replying to @ManishEarth @sgrif and
a == b is sugar for PartialEq::eq(&a, &b), not a.eq(&b). These are different, and more importantly the former situation can't be figured out as a simple search
1 reply 0 retweets 0 likes -
Assuming `a` does not have an inherent method named `eq`, I don't think those resolve differently at all. They certainly both fail in the same way with the code mentioned
2 replies 0 retweets 0 likes -
Replying to @sgrif @ManishEarth and
Don't get me wrong, there are definitely ambiguous situations you can get into when multiple methods are involved (if you can deref a twice and b once or a once and b twice and both are valid, which do you pick)?
1 reply 0 retweets 1 like -
Replying to @sgrif @ManishEarth and
But there are cases (such as original the one mentioned) where the answer is clearly unambiguous, and we already special case things like "there's only one impl of this trait".
1 reply 0 retweets 0 likes
IMO we could also just pick some rules that arbitrarily disambiguate the ambiguous case. If you've implemented both `MyTrait<TwoDeref> for OneDeref` to do something dramatically different than `MyTrait<OneDeref> for TwoDeref` your code is already ambiguous
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.