rust/library
Jonas Schievink 054c29d22c
Rollup merge of #80279 - Yaulendil:str-as-mut, r=m-ou-se
Implement missing `AsMut<str>` for `str`

Allows `&mut str` to be taken by a Generic which requires `T` such that `T: AsMut<str>`. Motivating example:

```rust
impl<'i, T> From<T> for StructImmut<'i> where
    T: AsRef<str> + 'i,
{
    fn from(asref: T) -> Self {
        let string: &str = asref.as_ref();
        //  ...
    }
}

impl<'i, T> From<T> for StructMut<'i> where
    T: AsMut<str> + 'i,
{
    fn from(mut asmut: T) -> Self {
        let string: &mut str = asmut.as_mut();
        //  ...
    }
}
```

The Immutable form of this structure can be constructed by `StructImmut::from(s)` where `s` may be a `&String` or a `&str`, because `AsRef<str>` is implemented for `str`. However, the mutable form of the structure can be constructed in the same way **only** with a `&mut String`, and **not** with a `&mut str`.

This change does have some precedent, because as can be seen in [the Implementors](https://doc.rust-lang.org/std/convert/trait.AsMut.html#implementors), `AsMut<[T]>` is implemented for `[T]` as well as for `Vec<T>`, but `AsMut<str>` is implemented only for `String`. This would complete the symmetry.

As a trait implementation, this should be immediately stable.
2021-01-31 01:47:23 +01:00
..
alloc Rollup merge of #79285 - yoshuawuyts:stabilize-arc_mutate_strong_count, r=m-ou-se 2021-01-31 01:47:20 +01:00
backtrace@af078ecc0b
core Rollup merge of #80279 - Yaulendil:str-as-mut, r=m-ou-se 2021-01-31 01:47:23 +01:00
panic_abort
panic_unwind fix another comment, and make __rust_start_panic code a bit more semantically clear 2020-12-25 23:37:27 +01:00
proc_macro Bump bootstrap compiler to 1.50 beta 2020-12-30 09:27:19 -05:00
profiler_builtins
rtstartup Bump bootstrap compiler to 1.50 beta 2020-12-30 09:27:19 -05:00
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #78044 - oberien:empty-seek, r=m-ou-se 2021-01-31 01:47:18 +01:00
stdarch@9c732a56f6
term
test Rollup merge of #80053 - gilescope:include-ignore, r=m-ou-se 2021-01-31 01:47:22 +01:00
unwind Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable 2021-01-09 12:50:08 +08:00