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

Yuya Nishihara yuya at tcha.org
Sat Jun 29 23:34:24 EDT 2019


> +    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?


More information about the Mercurial-devel mailing list