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

use deriving for DeepClone #6712

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
15 changes: 1 addition & 14 deletions src/libstd/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,11 @@ Similar to a mutable option type, but friendlier.
*/

#[mutable]
#[deriving(Clone)]
#[deriving(Clone, DeepClone, Eq)]
pub struct Cell<T> {
priv value: Option<T>
}

impl<T: DeepClone> DeepClone for Cell<T> {
fn deep_clone(&self) -> Cell<T> {
Cell{value: self.value.deep_clone()}
}
}

impl<T:cmp::Eq> cmp::Eq for Cell<T> {
fn eq(&self, other: &Cell<T>) -> bool {
(self.value) == (other.value)
}
fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
}

/// Creates a new full cell with the given value.
pub fn Cell<T>(value: T) -> Cell<T> {
Cell { value: Some(value) }
Expand Down
11 changes: 1 addition & 10 deletions src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,12 @@ use clone::DeepClone;
#[cfg(test)] use str;

/// The option type
#[deriving(Clone, Eq)]
#[deriving(Clone, DeepClone, Eq)]
pub enum Option<T> {
None,
Some(T),
}

impl<T: DeepClone> DeepClone for Option<T> {
fn deep_clone(&self) -> Option<T> {
match *self {
Some(ref x) => Some(x.deep_clone()),
None => None
}
}
}

impl<T:Ord> Ord for Option<T> {
fn lt(&self, other: &Option<T>) -> bool {
match (self, other) {
Expand Down