2021-11-22 08:26:34 +00:00
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
|
|
|
#[pyclass(immutable)]
|
|
|
|
pub struct Foo {
|
|
|
|
#[pyo3(get)]
|
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn borrow_mut_fails(foo: Py<Foo>, py: Python){
|
|
|
|
let borrow = foo.as_ref(py).borrow_mut();
|
|
|
|
}
|
|
|
|
|
2022-04-21 07:03:45 +00:00
|
|
|
#[pyclass(subclass)]
|
|
|
|
struct MutableBase;
|
|
|
|
|
|
|
|
#[pyclass(immutable, extends = MutableBase)]
|
|
|
|
struct ImmutableChild;
|
|
|
|
|
|
|
|
fn borrow_mut_of_child_fails(child: Py<ImmutableChild>, py: Python){
|
|
|
|
let borrow = child.as_ref(py).borrow_mut();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main(){}
|