changeset 52807:0fc15732fe7b

rust-pyo3: helper to return sets of revisions This will be less used than `revs_py_list`, but is better to separate here for readability of the caller (candidate in `InnerRevlog` to be implemented right afterwards).
author Georges Racinet <georges.racinet@cloudcrane.io>
date Tue, 24 Dec 2024 14:34:23 +0100
parents 0a0ed46ef6d6
children 6222326bd13e
files rust/hg-pyo3/src/revision.rs
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revision.rs	Tue Dec 24 01:29:07 2024 +0100
+++ b/rust/hg-pyo3/src/revision.rs	Tue Dec 24 14:34:23 2024 +0100
@@ -1,5 +1,5 @@
 use pyo3::prelude::*;
-use pyo3::types::PyList;
+use pyo3::types::{PyList, PySet};
 
 use hg::revlog::RevlogIndex;
 use hg::{BaseRevision, Revision, UncheckedRevision};
@@ -116,3 +116,14 @@
 {
     Ok(PyList::new(py, revs.into_iter().map(PyRevision::from))?.unbind())
 }
+
+#[allow(dead_code)]
+pub fn revs_py_set<U>(
+    py: Python<'_>,
+    revs: impl IntoIterator<Item = Revision, IntoIter = U>,
+) -> PyResult<Py<PySet>>
+where
+    U: ExactSizeIterator<Item = Revision>,
+{
+    Ok(PySet::new(py, revs.into_iter().map(PyRevision::from))?.unbind())
+}