Skip to content

Commit c3136d9

Browse files
committed
Add fn sync::Weak::allocator, remove A: Clone bound on Arc::unwrap_or_clone and From<Vec<T, A>> for Arc<[T], A>
1 parent 8cb474e commit c3136d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

library/alloc/src/sync.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,9 @@ impl<T: Clone, A: Allocator + Clone> Arc<T, A> {
22452245
// either unique to begin with, or became one upon cloning the contents.
22462246
unsafe { Self::get_mut_unchecked(this) }
22472247
}
2248+
}
22482249

2250+
impl<T: Clone, A: Allocator> Arc<T, A> {
22492251
/// If we have the only reference to `T` then unwrap it. Otherwise, clone `T` and return the
22502252
/// clone.
22512253
///
@@ -2675,6 +2677,13 @@ impl<T: ?Sized> Weak<T> {
26752677
}
26762678

26772679
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+
26782687
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
26792688
///
26802689
/// 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> {
34793488

34803489
#[cfg(not(no_global_oom_handling))]
34813490
#[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> {
34833492
/// Allocate a reference-counted slice and move `v`'s items into it.
34843493
///
34853494
/// # Example

0 commit comments

Comments
 (0)