@@ -2245,7 +2245,9 @@ impl<T: Clone, A: Allocator + Clone> Arc<T, A> {
2245
2245
// either unique to begin with, or became one upon cloning the contents.
2246
2246
unsafe { Self :: get_mut_unchecked ( this) }
2247
2247
}
2248
+ }
2248
2249
2250
+ impl < T : Clone , A : Allocator > Arc < T , A > {
2249
2251
/// If we have the only reference to `T` then unwrap it. Otherwise, clone `T` and return the
2250
2252
/// clone.
2251
2253
///
@@ -2675,6 +2677,13 @@ impl<T: ?Sized> Weak<T> {
2675
2677
}
2676
2678
2677
2679
impl < T : ?Sized , A : Allocator > Weak < T , A > {
2680
+ /// Returns a reference to the underlying allocator.
2681
+ #[ inline]
2682
+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
2683
+ pub fn allocator ( & self ) -> & A {
2684
+ & self . alloc
2685
+ }
2686
+
2678
2687
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
2679
2688
///
2680
2689
/// The pointer is valid only if there are some strong references. The pointer may be dangling,
@@ -3479,7 +3488,7 @@ impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Arc<T, A> {
3479
3488
3480
3489
#[ cfg( not( no_global_oom_handling) ) ]
3481
3490
#[ stable( feature = "shared_from_slice" , since = "1.21.0" ) ]
3482
- impl < T , A : Allocator + Clone > From < Vec < T , A > > for Arc < [ T ] , A > {
3491
+ impl < T , A : Allocator > From < Vec < T , A > > for Arc < [ T ] , A > {
3483
3492
/// Allocate a reference-counted slice and move `v`'s items into it.
3484
3493
///
3485
3494
/// # Example
0 commit comments