]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
rust/protover: delete ProtoSet::retain
authorcypherpunks <cypherpunks@torproject.org>
Wed, 15 Aug 2018 03:23:08 +0000 (03:23 +0000)
committercypherpunks <cypherpunks@torproject.org>
Fri, 14 Sep 2018 15:10:22 +0000 (15:10 +0000)
As the comment noted, it was horribly inefficient.

src/rust/protover/protoset.rs

index 27c16c7005e6641acf30a924390133eb24b2d16d..465b8f28509dc6112804022c390f6160d37710ae 100644 (file)
@@ -242,36 +242,6 @@ impl ProtoSet {
         false
     }
 
-    /// Retain only the `Version`s in this `ProtoSet` for which the predicate
-    /// `F` returns `true`.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// # use protover::errors::ProtoverError;
-    /// use protover::protoset::ProtoSet;
-    ///
-    /// # fn do_test() -> Result<bool, ProtoverError> {
-    /// let mut protoset: ProtoSet = "1,3-5,9".parse()?;
-    ///
-    /// // Keep only versions less than or equal to 8:
-    /// protoset.retain(|x| x <= &8);
-    ///
-    /// assert_eq!(protoset.expand(), vec![1, 3, 4, 5]);
-    /// #
-    /// # Ok(true)
-    /// # }
-    /// # fn main() { do_test(); }  // wrap the test so we can use the ? operator
-    /// ```
-    // XXX we could probably do something more efficient here. â€”isis
-    pub fn retain<F>(&mut self, f: F)
-        where F: FnMut(&Version) -> bool
-    {
-        let mut expanded: Vec<Version> = self.clone().expand();
-        expanded.retain(f);
-        *self = expanded.into();
-    }
-
     /// Returns all the `Version`s in `self` which are not also in the `other`
     /// `ProtoSet`.
     ///