Make ToPyObject impl for HashSet accept non-default hashers.

This commit is contained in:
Ohad Ravid 2021-06-27 14:36:12 +03:00
parent 11f1a1d6f0
commit 43fca5dad7
2 changed files with 3 additions and 1 deletions

View file

@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Use `METH_FASTCALL` argument passing convention, when possible, to improve `#[pyfunction]` and method performance.
[#1619](https://github.com/PyO3/pyo3/pull/1619), [#1660](https://github.com/PyO3/pyo3/pull/1660)
- Make the `Py_tracefunc` parameter of the `PyEval_SetProfile`/`PyEval_SetTrace` functions optional. [#1692](https://github.com/PyO3/pyo3/pull/1692)
- Make `ToPyObject` impl for `HashSet` accept non-default hashers. [#1702](https://github.com/PyO3/pyo3/pull/1702)
### Removed

View file

@ -183,9 +183,10 @@ impl<'a> std::iter::IntoIterator for &'a PySet {
}
}
impl<T> ToPyObject for collections::HashSet<T>
impl<T, S> ToPyObject for collections::HashSet<T, S>
where
T: hash::Hash + Eq + ToPyObject,
S: hash::BuildHasher + Default,
{
fn to_object(&self, py: Python) -> PyObject {
let set = PySet::new::<T>(py, &[]).expect("Failed to construct empty set");