[][src]Struct pyo3::PyRefMut

pub struct PyRefMut<'a, T: PyTypeInfo>(_, _);

Mutable version of PyRef.

Example

use pyo3::prelude::*;
use pyo3::types::IntoPyDict;
#[pyclass]
struct Point {
    x: i32,
    y: i32,
}
#[pymethods]
impl Point {
    fn length(&self) -> i32 {
        self.x * self.y
    }
}
let gil = Python::acquire_gil();
let py = gil.python();
let mut obj = PyRefMut::new(gil.python(), Point { x: 3, y: 4 }).unwrap();
let d = vec![("p", obj.to_object(py))].into_py_dict(py);
obj.x = 5; obj.y = 20;
py.run("assert p.length() == 100", None, Some(d)).unwrap();

Methods

impl<'p, T> PyRefMut<'p, T> where
    T: PyTypeInfo + PyTypeObject + PyTypeCreate
[src]

pub fn new(py: Python<'p>, value: T) -> PyResult<PyRefMut<T>>[src]

Trait Implementations

impl<'a, T: PyTypeInfo> AsPyPointer for PyRefMut<'a, T>[src]

impl<'a, T: PyTypeInfo> ToPyObject for PyRefMut<'a, T>[src]

impl<'a, T: PyTypeInfo> IntoPy<PyObject> for PyRefMut<'a, T>[src]

impl<'p, T> FromPyPointer<'p> for PyRefMut<'p, T> where
    T: PyTypeInfo
[src]

impl<'a, T> From<PyRefMut<'a, T>> for Py<T> where
    T: PyTypeInfo
[src]

impl<'a, T> From<PyRefMut<'a, T>> for &'a PyAny where
    T: PyTypeInfo
[src]

impl<'a, T: PyTypeInfo> Deref for PyRefMut<'a, T>[src]

type Target = T

The resulting type after dereferencing.

impl<'a, T: PyTypeInfo> DerefMut for PyRefMut<'a, T>[src]

impl<'a, T: Debug + PyTypeInfo> Debug for PyRefMut<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !Send for PyRefMut<'a, T>

impl<'a, T> !Sync for PyRefMut<'a, T>

impl<'a, T> Unpin for PyRefMut<'a, T>

impl<'a, T> !UnwindSafe for PyRefMut<'a, T>

impl<'a, T> !RefUnwindSafe for PyRefMut<'a, T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]