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

Implement IntoPy<PyObject> for BigInts #622

Merged
merged 1 commit into from
Oct 12, 2019
Merged

Conversation

kngwyu
Copy link
Member

@kngwyu kngwyu commented Oct 12, 2019

For #618

@kngwyu kngwyu merged commit e6ad49b into PyO3:master Oct 12, 2019
@programmerjake
Copy link
Contributor

Is there a reason IntoPy was implemented instead of the more generic FromPy?

@kngwyu kngwyu deleted the bigint-topyobj branch October 14, 2019 06:59
@kngwyu
Copy link
Member Author

kngwyu commented Oct 14, 2019

No, but I don't think FromPy is more generic.

@programmerjake
Copy link
Contributor

It is more generic, in the sense that a FromPy implementation gives you an implementation for both FromPy and IntoPy, but implementing IntoPy doesn't give you a FromPy implementation.

This is entirely analogous to why implementing From should be preferred to implementing Into whenever possible, as explained in the docs for Into:

One should only implement Into if a conversion to a type outside the current crate is
required. Otherwise one should always prefer implementing From over Into because
implementing From automatically provides one with a implementation of Into thanks to
the blanket implementation in the standard library. From cannot do these type of
conversions because of Rust's orphaning rules.

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.

2 participants