mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 21:16:27 +03:00
eb68b36521
Add unstable Share trait Tracking issue: rust-lang/rust#156756 This adds an initial unstable `Share` trait for clone-as-alias types, as part of the 2026 ergonomic ref-counting project goal. ```rust pub trait Share: Clone { fn share(&self) -> Self { Clone::clone(self) } } ``` This PR adds a separate unstable feature gate: ```rust #![feature(share_trait)] ``` and places the trait next to `Clone` in `core::clone`. Implemented initial impls: - `impl<T: ?Sized> Share for &T` - `impl<T: ?Sized, A: Allocator + Clone> Share for Rc<T, A>` - `impl<T: ?Sized, A: Allocator + Clone> Share for Arc<T, A>` - `impl<T> Share for std::sync::mpsc::Sender<T>` - `impl<T> Share for std::sync::mpsc::SyncSender<T>` The PR deliberately does not add `Share` to the prelude. r? @nikomatsakis @rustbot label F-ergonomic_clones