-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for TryFrom/TryInto traits #33417
Comments
Implement RFC 1542 cc rust-lang#33417 r? @aturon
Implement RFC 1542 cc rust-lang#33417 r? @aturon
Is there a way to generically print an error with the original value if the conversion fails without requiring |
A discussion of whether this should go in the prelude is pending for when this goes stable. |
Apologies if this is covered somewhere else, but what would we like to see before marking this as stable? I'm pretty sure I've reimplemented this functionality a few times in various projects, so a common reusable trait would make me 😄 |
We can bring it up for discussion for the next cycle. |
🔔 This issue is now entering a cycle-long final comment period for stabilization 🔔 As a point of stabilization, the libs team would also like to add these traits to the prelude as part of their stabilization. This will require a crater run being 100% clean at minimum, but we're relatively confident that the current state of resolve makes it backwards compatible to add traits to the prelude. |
I have a few questions about the purpose of these traits.
|
cc @sfackler, could you expand on the current set of impls and some of the rationale as well? |
I think in general the intuition should be exactly the same for that of In general, I don't think it should be expected that all types should |
When a |
@SimonSapin that would break an |
@sfackler Not if you use plain |
That doesn't appear to have happened yet so I don't know if it's because nobody has got round to it or there are no applicable types in
The issue is that if you want to use
Does this mean the error type is somehow fixed based on the type you're converting to? |
Why |
Stabilize TryFrom and TryInto with a convert::Infallible empty enum This is the plan proposed in #33417 (comment)
Expand docs for `TryFrom` and `TryInto`. The examples are still lacking for now, both for module docs and for methods/impl's. Will be adding those in further pushes. Should hopefully resolve the doc concern in rust-lang#33417 when finished?
Expand docs for `TryFrom` and `TryInto`. The examples are still lacking for now, both for module docs and for methods/impl's. Will be adding those in further pushes. Should hopefully resolve the doc concern in rust-lang#33417 when finished?
How can I help with documentation? :-) |
Oh I thought #58015 had landed, but it hasn’t yet… Let’s discuss it there. |
Expand docs for `TryFrom` and `TryInto`. The examples are still lacking for now, both for module docs and for methods/impl's. Will be adding those in further pushes. Should hopefully resolve the doc concern in #33417 when finished?
Could fn check(value: &T) -> bool |
One way to work with non-consuming impossible conversion could be to return the consumed non-convertible value along with the associated error. |
Wait...this shouldn't actually close until landing on stable Thursday, right? |
No, we close tracking issues when the PR stabilizing the feature lands on master. |
No, we usually close tracking issue when the stabilization or removal lands in the |
Tracking issues are closed by the PR that stabilizes them. Depending on the release cycle, this could be up to 12 weeks before stable is released. |
Got it. Thanks for the clarification, everyone! :) |
@gregdegruy update your version of Rust to 1.34 or higher. |
327: Either crate style methods for EitherOrBoth r=jswrenn a=Avi-D-coder I have recently been using `zip_longest`. Without Functors or lens it's a bit of a pain. @bluss's [either crate](https://crates.io/crates/either) has methods to make dealing with either variants nicer, so I added some of them. I attempted to make the naming and implementation as similar as possible, but there are a few differences. A fallible method of converting `EitherOrBoth` into an `either` would be very useful providing exclusive (not including `Both` variant) methods. Converting should probably wait for rust-lang/rust#33417. Co-authored-by: Avi ד <[email protected]>
We enable the "nightly" feature to get better error messages. Nightly is needed to build this project anyway until `TryFrom` lands [RFC], [tracking issue]. [1]: https://github.com/Geal/nom [RFC]: https://github.com/tbu-/rust-rfcs/blob/a4a22d7c5dd71724bb2cd0fe2db5026338d0b270/text/1542-try-from.md [tracking issue]: rust-lang/rust#33417
Tracking issue: rust-lang/rust#33417 [git filter-repo] original commit: rust-lang/rust@e53a2a7
Tracking issue for rust-lang/rfcs#1542
To do:
TryFrom
blanket impl to useInto
instead ofFrom
#56796 Change bounds onTryFrom
blanket impl to useInto
instead ofFrom
The text was updated successfully, but these errors were encountered: