[PATCH 10 of 10] rust-cpython: add safe way to map PyLeakedRef<&T> to PyLeakedRef<U>

Raphaël Gomès raphael.gomes at octobus.net
Thu Oct 10 07:53:54 EDT 2019


Is it not possible to just take a `fn` type? It forces a non-capturing fn.

On 10/8/19 7:16 PM, Yuya Nishihara wrote:
> +    pub fn map<U>(
> +        mut self,
> +        py: Python,
> +        f: impl FnOnce(T) -> U,
> +    ) -> PyLeakedRef<U> {
> +        PyLeakedRef {
> +            inner: self.inner.clone_ref(py),
> +            data: Some(f(self.data.take().unwrap())),
> +            py_shared_state: self.py_shared_state,
> +        }
> +    }


More information about the Mercurial-devel mailing list