so how come rust can do this? what's in its type system that makes it ok
-
-
Replying to @mountain_ghosts @tef
I don't think it can, can it? Do you have an example of this working?
2 replies 0 retweets 0 likes -
Replying to @DRMacIver @tef
yes, you can implement, say, Into<T> for multiple T on the same type, and then `let x: T = thing.into()` figures out which into() you meant
3 replies 0 retweets 2 likes -
Replying to @mountain_ghosts @tef
Oh, right, neat. Without knowing much about how this works (because I've just found out that it does), it's presumably because the resolution is more like a type class than dynamic dispatch, so has access to more than just the type of `thing` when resolving it.
2 replies 0 retweets 2 likes -
-
Replying to @mountain_ghosts
Yeah, I realise that, but it's more a case of which information is visible in dispatch. Dispatch is a mix of of statically and dynamically decided in Java, but the expected return type is not part of the available information (amusingly, it *is* at the bytecode level)
2 replies 0 retweets 0 likes -
Replying to @DRMacIver
oh right, yes okay -- in rust, the expected return is part of the dispatch, like in haskell; `let x: T = thing.into()` desugars to `let x = Into<T>::into(thing)`
1 reply 0 retweets 1 like -
-
Replying to @DRMacIver @mountain_ghosts
(though I don't thinkt hat's the correct syntax for the desugaring and I'm not clear on whether it's possible to explicitly write down the desugar in Rust)
2 replies 0 retweets 0 likes -
Replying to @DRMacIver
yeah I think I frequently write things that aren't valid; I think `let x = <thing as Into<T>>::into()` might be valid?
2 replies 0 retweets 0 likes
UFCS for this would be <U as Into<T>>::into(thing) T::from(thing) would be more idiomatic if the type can't be inferred for Into
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.