@@ -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
///
@@ -2591,6 +2593,13 @@ impl<T> Weak<T> {
2591
2593
}
2592
2594
2593
2595
impl < T , A : Allocator > Weak < T , A > {
2596
+ /// Returns a reference to the underlying allocator.
2597
+ #[ inline]
2598
+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
2599
+ pub fn allocator ( & self ) -> & A {
2600
+ & self . alloc
2601
+ }
2602
+
2594
2603
/// Constructs a new `Weak<T, A>`, without allocating any memory, technically in the provided
2595
2604
/// allocator.
2596
2605
/// Calling [`upgrade`] on the return value always gives [`None`].
@@ -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