Skip to content

Commit

Permalink
Update for PyO3 0.20.0.
Browse files Browse the repository at this point in the history
With lots of help from @davidhewitt
  • Loading branch information
Julian committed Nov 3, 2023
1 parent c201954 commit 4d68de0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
41 changes: 24 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rpds-py"
version = "0.10.6"
version = "0.11.0"
edition = "2021"

[lib]
Expand All @@ -12,5 +12,5 @@ rpds = "1.0.1"
archery = "1.0.0"

[dependencies.pyo3]
version = "0.19.2"
version = "0.20.0"
features = ["extension-module"]
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl IntoPy<PyObject> for Key {
}
}

impl AsPyPointer for Key {
unsafe impl AsPyPointer for Key {
fn as_ptr(&self) -> *mut pyo3::ffi::PyObject {
self.inner.as_ptr()
}
Expand Down Expand Up @@ -133,7 +133,7 @@ impl HashTrieMapPy {
let contents = self.inner.into_iter().map(|(k, v)| {
format!(
"{}: {}",
k.into_py(py),
k.clone().into_py(py),
v.call_method0(py, "__repr__")
.and_then(|r| r.extract(py))
.unwrap_or("<repr error>".to_owned())
Expand Down Expand Up @@ -188,8 +188,8 @@ impl HashTrieMapPy {
self.inner.values().collect::<Vec<&PyObject>>()
}

fn items(&self) -> Vec<(&Key, &PyObject)> {
self.inner.iter().collect::<Vec<(&Key, &PyObject)>>()
fn items(&self) -> Vec<(Key, &PyObject)> {
self.inner.iter().map(|(k, v)| (k.clone(), v)).collect()
}

fn discard(&self, key: Key) -> PyResult<HashTrieMapPy> {
Expand Down Expand Up @@ -318,7 +318,8 @@ impl HashTrieSetPy {

fn __repr__(&self, py: Python) -> String {
let contents = self.inner.into_iter().map(|k| {
k.into_py(py)
k.clone()
.into_py(py)
.call_method0(py, "__repr__")
.and_then(|r| r.extract(py))
.unwrap_or("<repr failed>".to_owned())
Expand Down

0 comments on commit 4d68de0

Please sign in to comment.