1
Fork 0

Rollup merge of #61313 - Centril:simplify-set1-insert, r=varkor

Simplify Set1::insert

r? @varkor
This commit is contained in:
Oliver Scherer 2019-05-29 14:41:13 +02:00 committed by GitHub
commit b742d7ee6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -170,16 +170,11 @@ pub enum Set1<T> {
impl<T: PartialEq> Set1<T> {
pub fn insert(&mut self, value: T) {
if let Set1::Empty = *self {
*self = Set1::One(value);
return;
}
if let Set1::One(ref old) = *self {
if *old == value {
return;
}
}
*self = Set1::Many;
*self = match self {
Set1::Empty => Set1::One(value),
Set1::One(old) if *old == value => return,
_ => Set1::Many,
};
}
}