diff options
| author | Philipp Brüschweiler <blei42@gmail.com> | 2013-06-04 14:08:25 +0200 |
|---|---|---|
| committer | Philipp Brüschweiler <blei42@gmail.com> | 2013-06-04 14:08:25 +0200 |
| commit | 3ce75e786de9945338c862fd73cc86fd6f892436 (patch) | |
| tree | 312a0fbd8384e33894da02b26c809d0c84ecfc6c /src/libstd | |
| parent | e1c1c059c6d120d324a0a2d5125363c21ad11940 (diff) | |
| download | rust-3ce75e786de9945338c862fd73cc86fd6f892436.tar.gz rust-3ce75e786de9945338c862fd73cc86fd6f892436.zip | |
std::util: Modernize NonCopyable constructor
part of #3853
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/option.rs | 2 | ||||
| -rw-r--r-- | 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 b9d04edd8a3..2386a779235 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 e8e68ddd632..6e72246ec60 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 { } |
