Skip to content

Commit

Permalink
Merge pull request exercism#123 from IanWhitney/update_custom_set
Browse files Browse the repository at this point in the history
Update Custom Set to follow new standard suite
  • Loading branch information
IanWhitney committed May 16, 2016
2 parents 52d58d4 + 8c197fc commit c06ae40
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 297 deletions.
17 changes: 0 additions & 17 deletions exercises/custom-set/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ impl<T: Ord + Clone> CustomSet<T> {
}
}

pub fn delete(&mut self, element: &T) {
self.collection.retain(|x| x != element)
}

pub fn contains(&self, other: &T) -> bool {
self.collection.contains(other)
}
Expand All @@ -37,10 +33,6 @@ impl<T: Ord + Clone> CustomSet<T> {
self.collection.is_empty()
}

pub fn size(&self) -> usize {
self.collection.len()
}

pub fn is_subset(&self, other: &Self) -> bool {
self.collection.iter().all(|x| other.contains(x))
}
Expand Down Expand Up @@ -72,13 +64,4 @@ impl<T: Ord + Clone> CustomSet<T> {
.filter(|c| !other.contains(c))
.collect())
}

pub fn symmetric_difference(&self, other: &Self) -> CustomSet<T> {
CustomSet::new(self.difference(other)
.collection
.iter()
.cloned()
.chain(other.difference(self).collection.iter().cloned())
.collect())
}
}
Loading

0 comments on commit c06ae40

Please sign in to comment.