Simplify Set1::insert.
This commit is contained in:
parent
4b9d80325a
commit
3f3087bb7f
1 changed files with 5 additions and 10 deletions
|
@ -170,16 +170,11 @@ pub enum Set1<T> {
|
||||||
|
|
||||||
impl<T: PartialEq> Set1<T> {
|
impl<T: PartialEq> Set1<T> {
|
||||||
pub fn insert(&mut self, value: T) {
|
pub fn insert(&mut self, value: T) {
|
||||||
if let Set1::Empty = *self {
|
*self = match self {
|
||||||
*self = Set1::One(value);
|
Set1::Empty => Set1::One(value),
|
||||||
return;
|
Set1::One(old) if *old == value => return,
|
||||||
}
|
_ => Set1::Many,
|
||||||
if let Set1::One(ref old) = *self {
|
};
|
||||||
if *old == value {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*self = Set1::Many;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue