rust/library
Matthias Krüger 13e284033e
Rollup merge of #92444 - dtolnay:coremethods, r=joshtriplett
Consolidate Result's and Option's methods into fewer impl blocks

`Result`'s and `Option`'s methods have historically been separated up into `impl` blocks based on their trait bounds, with the bounds specified on type parameters of the impl block. I find this unhelpful because closely related methods, like `unwrap_or` and `unwrap_or_default`, end up disproportionately far apart in source code and rustdocs:

<pre>
impl&lt;T&gt; Option&lt;T&gt; {
    pub fn unwrap_or(self, default: T) -&gt; T {
        ...
    }

    <img alt="one eternity later" src="https://user-images.githubusercontent.com/1940490/147780325-ad4e01a4-c971-436e-bdf4-e755f2d35f15.jpg" width="750">
}

impl&lt;T: Default&gt; Option&lt;T&gt; {
    pub fn unwrap_or_default(self) -&gt; T {
        ...
    }
}
</pre>

I'd prefer for method to be in as few impl blocks as possible, with the most logical grouping within each impl block. Any bounds needed can be written as `where` clauses on the method instead:

```rust
impl<T> Option<T> {
    pub fn unwrap_or(self, default: T) -> T {
        ...
    }

    pub fn unwrap_or_default(self) -> T
    where
        T: Default,
    {
        ...
    }
}
```

*Warning: the end-to-end diff of this PR is computed confusingly by git / rendered confusingly by GitHub; it's practically impossible to review that way. I've broken the PR into commits that move small groups of methods for which git behaves better &mdash; these each should be easily individually reviewable.*
2022-01-03 14:44:21 +01:00
..
alloc Rollup merge of #92463 - thomcc:thats-not-how-its-pronounced, r=joshtriplett 2022-01-01 22:49:52 +01:00
backtrace@b02ed04a7e Updated backtrace submodule 2021-11-02 12:31:34 +01:00
core Rollup merge of #92444 - dtolnay:coremethods, r=joshtriplett 2022-01-03 14:44:21 +01:00
panic_abort Stabilize asm! and global_asm! 2021-12-12 11:20:03 +00:00
panic_unwind Fix a bunch of typos 2021-12-14 16:40:43 +01:00
portable-simd Merge commit '533f0fc81ab9ba097779fcd27c8f9ea12261fef5' into psimd 2021-12-17 15:10:53 +08:00
proc_macro made compiler happy 2021-12-14 16:42:16 +05:30
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgr 2022-01-02 00:20:04 +00:00
stdarch@0716b22e90 update stdarch 2021-12-15 10:22:03 +08:00
test Remove unused allow deprecated 2021-12-29 18:06:01 +01:00
unwind Android: -ldl must appear after -lgcc when linking 2021-11-30 02:42:35 +00:00