diff --git a/src/collections/sets.rs b/src/collections/sets.rs index ee00c2983f8283ab04a7a4d5b75f277c238c7f87..a93d6f8df3c732fd08608df15a18535fe90e6ab2 100644 --- a/src/collections/sets.rs +++ b/src/collections/sets.rs @@ -72,15 +72,18 @@ impl VecSet { self.inner.pop() } + /// Pushes a new element into the set. Returns `false` if it was already + /// present and `true` if it is newly added. #[inline] - pub fn push(&mut self, to_push: T) { + pub fn push(&mut self, to_push: T) -> bool { for element in self.inner.iter() { if *element == to_push { - return; + return false; } } self.inner.push(to_push); + return true } #[inline]