@@ -2256,7 +2256,9 @@ impl<T: Clone, A: Allocator + Clone> Arc<T, A> {
2256
2256
// either unique to begin with, or became one upon cloning the contents.
2257
2257
unsafe { Self :: get_mut_unchecked ( this) }
2258
2258
}
2259
+ }
2259
2260
2261
+ impl < T : Clone , A : Allocator > Arc < T , A > {
2260
2262
/// If we have the only reference to `T` then unwrap it. Otherwise, clone `T` and return the
2261
2263
/// clone.
2262
2264
///
@@ -2690,6 +2692,13 @@ impl<T: ?Sized> Weak<T> {
2690
2692
}
2691
2693
2692
2694
impl < T : ?Sized , A : Allocator > Weak < T , A > {
2695
+ /// Returns a reference to the underlying allocator.
2696
+ #[ inline]
2697
+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
2698
+ pub fn allocator ( & self ) -> & A {
2699
+ & self . alloc
2700
+ }
2701
+
2693
2702
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
2694
2703
///
2695
2704
/// The pointer is valid only if there are some strong references. The pointer may be dangling,
@@ -3494,7 +3503,7 @@ impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Arc<T, A> {
3494
3503
3495
3504
#[ cfg( not( no_global_oom_handling) ) ]
3496
3505
#[ stable( feature = "shared_from_slice" , since = "1.21.0" ) ]
3497
- impl < T , A : Allocator + Clone > From < Vec < T , A > > for Arc < [ T ] , A > {
3506
+ impl < T , A : Allocator > From < Vec < T , A > > for Arc < [ T ] , A > {
3498
3507
/// Allocate a reference-counted slice and move `v`'s items into it.
3499
3508
///
3500
3509
/// # Example
0 commit comments