0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-12 04:38:06 +00:00
Jeffery To 06231ce8cb python-rpds-py: Add new package
From the README:

Python bindings to the Rust rpds crate for persistent data structures.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2023-11-30 12:57:27 +08:00

22 lines
597 B
Bash

#!/bin/sh
[ "$1" = python3-rpds-py ] || exit 0
python3 - << 'EOF'
from rpds import HashTrieMap, HashTrieSet, List
m = HashTrieMap({"foo": "bar", "baz": "quux"})
assert m.insert("spam", 37) == HashTrieMap({"foo": "bar", "baz": "quux", "spam": 37})
assert m.remove("foo") == HashTrieMap({"baz": "quux"})
s = HashTrieSet({"foo", "bar", "baz", "quux"})
assert s.insert("spam") == HashTrieSet({"foo", "bar", "baz", "quux", "spam"})
assert s.remove("foo") == HashTrieSet({"bar", "baz", "quux"})
L = List([1, 3, 5])
assert L.push_front(-1) == List([-1, 1, 3, 5])
assert L.rest == List([3, 5])
EOF