2021-11-22 08:26:34 +00:00
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
2022-06-11 11:20:43 +00:00
|
|
|
#[pyclass(frozen)]
|
2021-11-22 08:26:34 +00:00
|
|
|
pub struct Foo {
|
|
|
|
#[pyo3(get)]
|
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
2023-07-11 19:13:35 +00:00
|
|
|
#[pymethods]
|
|
|
|
impl Foo {
|
|
|
|
fn mut_method(&mut self) {}
|
|
|
|
}
|
|
|
|
|
2023-05-16 19:48:59 +00:00
|
|
|
fn borrow_mut_fails(foo: Py<Foo>, py: Python) {
|
2024-02-29 07:15:34 +00:00
|
|
|
let borrow = foo.bind(py).borrow_mut();
|
2021-11-22 08:26:34 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 07:03:45 +00:00
|
|
|
#[pyclass(subclass)]
|
|
|
|
struct MutableBase;
|
|
|
|
|
2022-06-11 11:20:43 +00:00
|
|
|
#[pyclass(frozen, extends = MutableBase)]
|
2022-04-21 07:03:45 +00:00
|
|
|
struct ImmutableChild;
|
|
|
|
|
2023-05-16 19:48:59 +00:00
|
|
|
fn borrow_mut_of_child_fails(child: Py<ImmutableChild>, py: Python) {
|
2024-02-29 07:15:34 +00:00
|
|
|
let borrow = child.bind(py).borrow_mut();
|
2022-04-21 07:03:45 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 19:48:59 +00:00
|
|
|
fn py_get_of_mutable_class_fails(class: Py<MutableBase>) {
|
|
|
|
class.get();
|
|
|
|
}
|
|
|
|
|
2024-03-03 14:47:25 +00:00
|
|
|
fn pyclass_get_of_mutable_class_fails(class: &Bound<'_, MutableBase>) {
|
2023-05-16 19:48:59 +00:00
|
|
|
class.get();
|
|
|
|
}
|
|
|
|
|
2023-07-11 19:13:35 +00:00
|
|
|
#[pyclass(frozen)]
|
|
|
|
pub struct SetOnFrozenClass {
|
|
|
|
#[pyo3(set)]
|
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
2023-05-16 19:48:59 +00:00
|
|
|
fn main() {}
|