-
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
Implement tuple<->array convertions via From
#97594
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
(rust-highfive has picked a reviewer for you, use r? to override) |
r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs |
@rustbot label -S-waiting-on-review +S-waiting-on-author |
This comment has been minimized.
This comment has been minimized.
I've removed
They all basically do the following: fn f() -> Result<(), ()> {
Ok(())?; // <--
Ok(())
} For this to work you need to infer IIRC this is not considered a breaking change per rust rules, because it can be fixed by adding types: fn f() -> Result<(), ()> {
Ok::<_, ()>(())?;
//^^^^^^^^^
Ok(())
} However I'm not sure how widespread this pattern is and if this is worth the potential breakage. |
@rustbot ready |
☔ The latest upstream changes (presumably #98807) made this pull request unmergeable. Please resolve the merge conflicts. |
46a44a8
to
156c906
Compare
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
ping from triage: What's the status of this PR? |
Looks like this is old enough that it pre-dates ACPs, so I'll nominate it for libs-api to say what they want. |
@camelid pretty much what the tags say: this is waiting on a |
We briefly discussed this in the libs-api meeting, and we were wondering if there are any motivating use cases. |
156c906
to
36f8693
Compare
This has passed FCP and the implementation looks good to me. The only thing I would ask for is some tests that exercise this properly. Especially because this is insta stable. Maybe doc tests? Some documentation wouldn't hurt either. E,g,, here, |
This comment has been minimized.
This comment has been minimized.
8ac5f61
to
de10516
Compare
Thanks! @bors r+ |
…risDenton Implement tuple<->array convertions via `From` This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths: ```rust impl<T> From<[T; 1]> for (T,) { ... } impl<T> From<[T; 2]> for (T, T) { ... } /* ... */ impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T) { ... } impl<T> From<(T,)> for [T; 1] { ... } impl<T> From<(T, T)> for [T; 2] { ... } /* ... */ impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12] { ... } ``` IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.
…risDenton Implement tuple<->array convertions via `From` This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths: ```rust impl<T> From<[T; 1]> for (T,) { ... } impl<T> From<[T; 2]> for (T, T) { ... } /* ... */ impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T) { ... } impl<T> From<(T,)> for [T; 1] { ... } impl<T> From<(T, T)> for [T; 2] { ... } /* ... */ impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12] { ... } ``` IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.
…risDenton Implement tuple<->array convertions via `From` This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths: ```rust impl<T> From<[T; 1]> for (T,) { ... } impl<T> From<[T; 2]> for (T, T) { ... } /* ... */ impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T) { ... } impl<T> From<(T,)> for [T; 1] { ... } impl<T> From<(T, T)> for [T; 2] { ... } /* ... */ impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12] { ... } ``` IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.
…earth Rollup of 10 pull requests Successful merges: - rust-lang#97594 (Implement tuple<->array convertions via `From`) - rust-lang#105452 (Add cross-language LLVM CFI support to the Rust compiler) - rust-lang#105695 (Replace generic thread parker with explicit no-op parker) - rust-lang#110371 (rustdoc: restructure type search engine to pick-and-use IDs) - rust-lang#110928 (tests: Add tests for LoongArch64) - rust-lang#110970 (tidy: remove ENTRY_LIMIT maximum checking and set it to 900) - rust-lang#111104 (Update ICU4X to 1.2) - rust-lang#111127 (Constify slice flatten method) - rust-lang#111146 (rustc_middle: Fix `opt_item_ident` for non-local def ids) - rust-lang#111154 (Use builtin FFX isolation for Fuchsia test runner) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixup "since" dates for `array_tuple_conv` feature Fixes a mistake from rust-lang#97594
Fixup "since" dates for `array_tuple_conv` feature Fixes a mistake from rust-lang#97594
This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths:
IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.