Skip to content

Commit

Permalink
std::util: Modernize NonCopyable constructor
Browse files Browse the repository at this point in the history
part of #3853
  • Loading branch information
Blei committed Jun 4, 2013
1 parent e1c1c05 commit 3ce75e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 5 additions & 3 deletions src/libstd/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down

4 comments on commit 3ce75e7

@bors
Copy link
Contributor

@bors bors commented on 3ce75e7 Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 3ce75e7 Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Blei/rust/fix-constructors = 3ce75e7 into auto

@bors
Copy link
Contributor

@bors bors commented on 3ce75e7 Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blei/rust/fix-constructors = 3ce75e7 merged ok, testing candidate = 3ceb0696

@bors
Copy link
Contributor

@bors bors commented on 3ce75e7 Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.