2019-12-17 17:36:56 +00:00
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
|
|
|
#[pyclass]
|
|
|
|
struct TestClass {
|
|
|
|
num: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[pymethods]
|
|
|
|
impl TestClass {
|
2021-04-17 21:22:06 +00:00
|
|
|
#[pyo3(name = "num")]
|
2019-12-17 17:36:56 +00:00
|
|
|
#[getter(number)]
|
|
|
|
fn get_num(&self) -> u32 { self.num }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[pymethods]
|
|
|
|
impl TestClass {
|
2021-04-17 21:22:06 +00:00
|
|
|
#[pyo3(name = "foo")]
|
|
|
|
#[pyo3(name = "bar")]
|
2019-12-17 17:36:56 +00:00
|
|
|
fn qux(&self) -> u32 { self.num }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[pymethods]
|
|
|
|
impl TestClass {
|
2021-04-17 21:22:06 +00:00
|
|
|
#[pyo3(name = "makenew")]
|
2019-12-17 17:36:56 +00:00
|
|
|
#[new]
|
|
|
|
fn new(&self) -> Self { Self { num: 0 } }
|
|
|
|
}
|
|
|
|
|
2023-09-30 21:51:52 +00:00
|
|
|
#[pymethods]
|
|
|
|
impl TestClass {
|
|
|
|
#[getter(1)]
|
|
|
|
fn get_one(&self) -> Self { Self { num: 0 } }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[pymethods]
|
|
|
|
impl TestClass {
|
|
|
|
#[getter = 1]
|
|
|
|
fn get_two(&self) -> Self { Self { num: 0 } }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-17 17:36:56 +00:00
|
|
|
fn main() {}
|