std::util: Modernize NonCopyable constructor

part of #3853
This commit is contained in:
Philipp Brüschweiler 2013-06-04 14:08:25 +02:00
parent e1c1c059c6
commit 3ce75e786d
2 changed files with 6 additions and 4 deletions

View File

@ -437,7 +437,7 @@ fn test_option_dance() {
}
#[test] #[should_fail] #[ignore(cfg(windows))]
fn test_option_too_much_dance() {
let mut y = Some(util::NonCopyable());
let mut y = Some(util::NonCopyable::new());
let _y2 = y.swap_unwrap();
let _y3 = y.swap_unwrap();
}

View File

@ -79,13 +79,15 @@ pub struct NonCopyable {
priv i: (),
}
impl NonCopyable {
/// Creates a dummy non-copyable structure and returns it for use.
pub fn new() -> NonCopyable { NonCopyable { i: () } }
}
impl Drop for NonCopyable {
fn finalize(&self) { }
}
/// Creates a dummy non-copyable structure and returns it for use.
pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }
/// A type with no inhabitants
pub enum Void { }