adding constructor and get/set

This commit is contained in:
Andy Pack 2023-05-06 16:16:48 +01:00
parent fbc5b099d6
commit debf43dff9
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7

View File

@ -2,9 +2,18 @@ use pyo3::prelude::*;
#[pyclass] #[pyclass]
pub struct Integer { pub struct Integer {
#[pyo3(get, set)]
inner: i32, inner: i32,
} }
#[pymethods]
impl Integer {
#[new]
fn new(value: i32) -> Integer {
Integer { inner: value }
}
}
// A "tuple" struct // A "tuple" struct
#[pyclass] #[pyclass]
pub struct Number(i32); pub struct Number(i32);