diff --git a/Cargo.lock b/Cargo.lock index cf44cb8..2a98491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.5.0" +version = "0.5.1" dependencies = [ "pyo3", "rpds", diff --git a/Cargo.toml b/Cargo.toml index 48c4d53..8e5130d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.5.0" +version = "0.5.1" edition = "2021" [lib] diff --git a/README.rst b/README.rst index 637ebba..a3e10a0 100644 --- a/README.rst +++ b/README.rst @@ -4,8 +4,7 @@ |PyPI| |Pythons| |CI| -.. |PyPI| image:: https://img.shields.io/pypi/v/rpds-py.svg - :alt: PyPI version +.. |PyPI| image:: https://img.shields.io/pypi/v/rpds-py.svg :alt: PyPI version :target: https://pypi.org/project/rpds-py/ .. |Pythons| image:: https://img.shields.io/pypi/pyversions/rpds-py.svg @@ -18,3 +17,30 @@ Python bindings to the Rust ``rpds`` crate. + +What's here is quite minimal (in transparency, it was written initially to support replacing ``pyrsistent`` in the `referencing library `_). +If you see something missing (which is very likely), a PR is definitely welcome to add it. + +Methods in general are named similarly to their ``rpds`` counterparts (rather than ``pyrsistent``\ 's conventions, though probably a full drop-in ``pyrsistent``\ -compatible wrapper module is a good addition at some point). + +.. code:: python + + >>> from rpds import HashTrieMap, HashTrieSet, List + + >>> m = HashTrieMap({"foo": "bar", "baz": "quux"}) + >>> m.insert("spam", 37) == HashTrieMap({"foo": "bar", "baz": "quux", "spam": 37}) + True + >>> m.remove("foo") == HashTrieMap({"baz": "quux"}) + True + + >>> s = HashTrieSet({"foo", "bar", "baz", "quux"}) + >>> s.insert("spam") == HashTrieSet({"foo", "bar", "baz", "quux", "spam"}) + True + >>> s.remove("foo") == HashTrieSet({"bar", "baz", "quux"}) + True + + >>> L = List([1, 3, 5]) + >>> L.push_front(-1) == List([-1, 1, 3, 5]) + True + >>> L.rest == List([3, 5]) + True