Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Default for CondVar, Mutex and RwLock #32807

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/libstd/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ impl Drop for Condvar {
}
}

#[unstable(feature = "defaults",
reason = "has not yet been decided",
issue = "31865")]
impl Default for Condvar {
fn default() -> Condvar {
Condvar::new()
}
}

impl StaticCondvar {
/// Creates a new condition variable
#[unstable(feature = "static_condvar",
Expand Down
9 changes: 9 additions & 0 deletions src/libstd/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ impl<T> Mutex<T> {
}
}

#[unstable(feature = "defaults",
reason = "has not yet been decided",
issue = "31865")]
impl<T: Default> Default for Mutex<T> {
fn default() -> Mutex<T> {
Mutex::new(Default::default())
}
}

impl<T: ?Sized> Mutex<T> {
/// Acquires a mutex, blocking the current thread until it is able to do so.
///
Expand Down
9 changes: 9 additions & 0 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ impl<T> RwLock<T> {
}
}

#[unstable(feature = "defaults",
reason = "has not yet been decided",
issue = "31865")]
impl<T: Default> Default for RwLock<T> {
fn default() -> RwLock<T> {
RwLock::new(Default::default())
}
}

impl<T: ?Sized> RwLock<T> {
/// Locks this rwlock with shared read access, blocking the current thread
/// until it can be acquired.
Expand Down