rust/library/alloc
Matthias Krüger fae72a07dd
Rollup merge of #137105 - zachs18:cow-derefpure-restrict, r=Nadrieril
Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.

Fixes #136046

`feature(deref_patterns)` tracking issue: https://github.com/rust-lang/rust/issues/87121

`Cow<'_, T>` should only implement `DerefPure` if its `Deref` impl is pure, which requires `<T::Owned as Borrow<T>>::borrow`  to be pure. This PR restricts `impl DerefPure for Cow<'_, T>` to `T: Sized + Clone`, `T = [U: Clone]`, and `T = str` (for all of whom `<T::Owned as Borrow<T>>::borrow` is implemented in the stdlib and is pure).

cc ``@Nadrieril``

------

An alternate approach would be to introduce a new `unsafe trait BorrowPure<T>` analogous to `DerefPure`  that could be implemented for `T: Sized`, `&T`, `&mut T`, `String`, `Vec`, `Box`, `PathBuf`, `OsString`, etc. https://github.com/rust-lang/rust/compare/master...zachs18:borrow-pure-trait
2025-02-17 06:38:15 +01:00
..
benches library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00
src Rollup merge of #137105 - zachs18:cow-derefpure-restrict, r=Nadrieril 2025-02-17 06:38:15 +01:00
tests library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00
Cargo.toml library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00