提交 edae4958 编写于 作者: M Mara Bos

Make {Mutex, Condvar, RwLock}::new() const.

上级 acc3ab4e
......@@ -122,6 +122,7 @@ impl Condvar {
/// let condvar = Condvar::new();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
#[must_use]
#[inline]
pub const fn new() -> Condvar {
......
......@@ -214,6 +214,7 @@ impl<T> Mutex<T> {
/// let mutex = Mutex::new(0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
#[inline]
pub const fn new(t: T) -> Mutex<T> {
Mutex {
......
......@@ -146,6 +146,7 @@ impl<T> RwLock<T> {
/// let lock = RwLock::new(5);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
#[inline]
pub const fn new(t: T) -> RwLock<T> {
RwLock {
......
......@@ -62,7 +62,7 @@ unsafe impl Sync for MovableMutex {}
impl MovableMutex {
/// Creates a new mutex.
#[inline]
pub fn new() -> Self {
pub const fn new() -> Self {
Self(imp::MovableMutex::new())
}
......
......@@ -75,7 +75,7 @@ fn drop(&mut self) {
impl MovableRwLock {
/// Creates a new reader-writer lock for use.
#[inline]
pub fn new() -> Self {
pub const fn new() -> Self {
Self(imp::MovableRwLock::new())
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册