From 3ce75e786de9945338c862fd73cc86fd6f892436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Tue, 4 Jun 2013 14:08:25 +0200 Subject: [PATCH] std::util: Modernize NonCopyable constructor part of #3853 --- src/libstd/option.rs | 2 +- src/libstd/util.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libstd/option.rs b/src/libstd/option.rs index b9d04edd8a3b..2386a779235d 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -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(); } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index e8e68ddd632e..6e72246ec60b 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -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 { }