Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Into with From for built-in types. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spwilson2
Copy link

https://doc.rust-lang.org/std/convert/trait.Into.html

Prior to Rust 1.41, if the destination type was not part of the current
crate then you couldn't implement From directly. This will fail to
compile in older versions of the language because Rust's orphaning rules
used to be a little bit more strict. To bypass this, you could implement
Into directly.

It is important to understand that Into does not provide a From
implementation (as From does with Into). Therefore, you should always
try to implement From and then fall back to Into if From can't be
implemented.

Signed-off-by: Sean Wilson spwilson27@gmail.com

https://doc.rust-lang.org/std/convert/trait.Into.html

Prior to Rust 1.41, if the destination type was not part of the current
crate then you couldn't implement From directly. This will fail to
compile in older versions of the language because Rust's orphaning rules
used to be a little bit more strict. To bypass this, you could implement
Into directly.

It is important to understand that Into does not provide a From
implementation (as From does with Into). Therefore, you should always
try to implement From and then fall back to Into if From can't be
implemented.

Signed-off-by: Sean Wilson <spwilson27@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant