mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Make Weak::new const
This commit is contained in:
parent
af446e1d70
commit
a358ad2aff
@ -2112,9 +2112,10 @@ impl<T> Weak<T> {
|
||||
/// assert!(empty.upgrade().is_none());
|
||||
/// ```
|
||||
#[stable(feature = "downgraded_weak", since = "1.10.0")]
|
||||
#[rustc_const_unstable(feature = "const_weak_new", issue = "95091", reason = "recently added")]
|
||||
#[must_use]
|
||||
pub fn new() -> Weak<T> {
|
||||
Weak { ptr: NonNull::new(usize::MAX as *mut RcBox<T>).expect("MAX is not 0") }
|
||||
pub const fn new() -> Weak<T> {
|
||||
Weak { ptr: unsafe { NonNull::new_unchecked(usize::MAX as *mut RcBox<T>) } }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1742,9 +1742,10 @@ impl<T> Weak<T> {
|
||||
/// assert!(empty.upgrade().is_none());
|
||||
/// ```
|
||||
#[stable(feature = "downgraded_weak", since = "1.10.0")]
|
||||
#[rustc_const_unstable(feature = "const_weak_new", issue = "95091", reason = "recently added")]
|
||||
#[must_use]
|
||||
pub fn new() -> Weak<T> {
|
||||
Weak { ptr: NonNull::new(usize::MAX as *mut ArcInner<T>).expect("MAX is not 0") }
|
||||
pub const fn new() -> Weak<T> {
|
||||
Weak { ptr: unsafe { NonNull::new_unchecked(usize::MAX as *mut ArcInner<T>) } }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user