D6394: rust-dirstate: add "dirs" rust-cpython binding

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Mon Jul 1 08:46:32 UTC 2019


Alphare added a comment.


  In D6394#96115 <https://phab.mercurial-scm.org/D6394#96115>, @yuja wrote:
  
  >> +    def __contains__(&self, item: PyObject) -> PyResult<bool> {
  >> +        Ok(self
  >> +            .dirs_map(py)
  >> +            .borrow()
  >> +            .get(&item.extract::<PyBytes>(py)?.data(py).to_owned())
  >> +            .is_some())
  >
  > `.contains_key(..)` and `.as_ref()` instead of `&...to_owned()`.
  > I'm surprised by the use of Deref in the previous patch. Is it legit
  > to leverage Deref to expose the inner type?
  
  Ah yes, I don't know what I was thinking. I'll write a follow up.
  To my eyes, the point of `Deref` is to make the `struct` act as a "fat pointer" from the outer interface code, but maybe this does not really help that much?

REPOSITORY
  rHG Mercurial

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

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

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


More information about the Mercurial-devel mailing list