]> git.lizzy.rs Git - enumset.git/commitdiff
Merge pull request #13 from epavese/insert_return_consistent
authorLymia Aluysia <lymia@lymiahugs.com>
Mon, 30 Mar 2020 13:41:58 +0000 (06:41 -0700)
committerGitHub <noreply@github.com>
Mon, 30 Mar 2020 13:41:58 +0000 (06:41 -0700)
return value for insert() was inconsistent with std sets

1  2 
enumset/src/lib.rs

index d97054e3a20a0a78bfd8a088ea8f2efaf2f2efb2,66f605f58324768b176230f368b388237e9b5013..b04aa1cc2a4b2f98ee0de5a8ef1889d42f6af672
@@@ -357,12 -342,8 +357,12 @@@ impl <T : EnumSetType> EnumSet<T> 
      }
  
      /// Adds a value to this set.
 +    ///
 +    /// If the set did not have this value present, `false` is returned.
 +    ///
 +    /// If the set did have this value present, `true` is returned.
      pub fn insert(&mut self, value: T) -> bool {
-         let contains = self.contains(value);
+         let contains = !self.contains(value);
          self.__enumset_underlying = self.__enumset_underlying | Self::mask(value.enum_into_u8());
          contains
      }