D6593: rust-minor-fixes: remove Deref in favor of explicit methods

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Thu Jul 4 20:13:34 EDT 2019


yuja added a comment.


  > impl DirsMultiset {
  >
  >   /// Initializes the multiset from a dirstate or a manifest.
  >   ///
  >
  > @@ -132,6 +123,22 @@
  >
  >       Ok(())
  >   }
  >
  > +
  > +    pub fn contains_key(&self, key: &[u8]) -> bool {
  > +        self.inner.contains_key(key)
  > +    }
  > +
  > +    pub fn iter(&self) -> Iter<Vec<u8>, u32> {
  > +        self.inner.iter()
  > +    }
  > +
  > +    pub fn len(&self) -> usize {
  > +        self.inner.len()
  > +    }
  > +
  > +    pub fn get(&self, key: &[u8]) -> Option<&u32> {
  > +        self.inner.get(key)
  > +    }
  
  Maybe these can be:
  
  - pub contains() -> inner.contains_key()
  - pub iter() -> inner.keys()
  - pub len() -> inner.len()
  - (not pub) get() -> inner.get()
  
  The point is that DirsMultiset should be more like a set regarding public API.
  
  `get() -> inner.get()` can be removed if we rewrite the tests to peek
  inner.get(), but I don't care much about that.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6593/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6593

To: Alphare, #hg-reviewers
Cc: yuja, durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list