1
Fork 0

Add Box::into_unique

This commit is contained in:
Simon Sapin 2017-07-14 12:47:06 +02:00
parent 1ef24bb3e2
commit cbd2b6b484
5 changed files with 48 additions and 21 deletions

View file

@ -280,7 +280,7 @@ impl<T> Arc<T> {
weak: atomic::AtomicUsize::new(1),
data: data,
};
Arc { ptr: unsafe { Shared::new_unchecked(Box::into_raw(x)) } }
Arc { ptr: Shared::from(Box::into_unique(x)) }
}
/// Returns the contained value, if the `Arc` has exactly one strong reference.
@ -842,7 +842,7 @@ impl<T> Weak<T> {
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Shared::new_unchecked(Box::into_raw(box ArcInner {
ptr: Shared::from(Box::into_unique(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),