pyo3_pytests/
objstore.rs

1use pyo3::prelude::*;
2
3#[pyclass]
4#[derive(Default)]
5pub struct ObjStore {
6    obj: Vec<PyObject>,
7}
8
9#[pymethods]
10impl ObjStore {
11    #[new]
12    fn new() -> Self {
13        ObjStore::default()
14    }
15
16    fn push(&mut self, obj: &Bound<'_, PyAny>) {
17        self.obj.push(obj.clone().unbind());
18    }
19}
20
21#[pymodule(gil_used = false)]
22pub fn objstore(m: &Bound<'_, PyModule>) -> PyResult<()> {
23    m.add_class::<ObjStore>()
24}
⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here