3 ms·
Thank you! This is the best explanation I've been able to find for how to use From, instead of Into. One thing that's useful about From is that you can impleme
by rbalicki 11y ago
Thank you! This is the best explanation I've been able to find for how to use From, instead of Into.
One thing that's useful about From is that you can implement From<SomePublicStruct> for YourPrivateStruct, but the compiler complains about Into<YourPrivateStruct> for SomePublicStruct.
SomePublicStruct could be (i32, i32) and YourPrivateStruct could be MyPoint, for example.
Making YourPrivateStruct public (with pub struct) fixes things, but that's not always what you want.
- steveklabnik 11y agoAny time. I myself checked in with IRC as I posted. :) Like I said, these traits are really new, and so they don't have great docs yet...