pub fn into_super(self) -> PyRef<'p, U> {
        let PyRef { inner } = self;
        std::mem::forget(self);
        PyRef {
            inner: &inner.ob_base,
        }
    }
/// Gets a `PyRef<T::BaseType>`.
///
/// While `as_ref()` returns a reference of type `&T::BaseType`, this cannot be
/// used to get the base of `T::BaseType`.
///
/// But with the help of this method, you can get hold of instances of the
/// super-superclass when needed.
///
/// # Examples
/// ```
/// # use pyo3::prelude::*;
/// #[pyclass(subclass)]
/// struct Base1 {
///     name1: &'static str,
/// }
/// #[pyclass(extends=Base1, subclass)]
/// struct Base2 {
///     name2: &'static str,
///  }
/// #[pyclass(extends=Base2)]
/// struct Sub {
///     name3: &'static str,
///  }
/// #[pymethods]
/// impl Sub {
///     #[new]
///     fn new() -> PyClassInitializer<Self> {
///         PyClassInitializer::from(Base1{ name1: "base1" })
///             .add_subclass(Base2 { name2: "base2" })
///             .add_subclass(Self { name3: "sub" })
///     }
///     fn name(slf: PyRef<Self>) -> String {
///         let subname = slf.name3;
///         let super_ = slf.into_super();
///         format!("{} {} {}", super_.as_ref().name1, super_.name2, subname)
///     }
/// }
/// # Python::with_gil(|py| {
/// #     let sub = PyCell::new(py, Sub::new()).unwrap();
/// #     pyo3::py_run!(py, sub, "assert sub.name() == 'base1 base2 sub'")
/// # });
/// ```


But with the help of this method, you can get hold of instances of the
super-superclass when needed.
But with the help of this method you can get hold of instances of the super - superclass when needed .
pub fn into_super(self) -> PyRef<'p, U> {
        let PyRef { inner } = self;
        std::mem::forget(self);
        PyRef {
            inner: &inner.ob_base,
        }
    }
pub fn into_super ( self ) -> PyRef < ' p , U > { let PyRef { inner } = self ; std :: mem :: forget ( self ) ; PyRef { inner : & inner . ob_base , } }
Gets a `PyRef<T::BaseType>`.
Gets a ` PyRef<T :: BaseType > ` .
self
self
examples
None
use pyo3::prelude::*;
None
[pyclass(subclass)]
struct Base1 {
name1: &'static str,
}
struct Base1 { name1 : & ' static str }
[pyclass(extends=base1, subclass)]
struct Base2 {
name2: &'static str,
}
struct Base2 { name2 : & ' static str }
[pyclass(extends=base2)]
struct Sub {
name3: &'static str,
}
struct Sub { name3 : & ' static str }
[pymethods]
impl Sub {
[new]
fn new() -> PyClassInitializer {
PyClassInitializer::from(Base1{ name1: "base1" })
.add_subclass(Base2 { name2: "base2" })
.add_subclass(Self { name3: "sub" })
}
fn name(slf: PyRef) -> String {
let subname = slf.name3;
let super_ = slf.into_super();
format!("{} {} {}", super_.as_ref().name1, super_.name2, subname)
}
}
impl Sub { [ new ] fn new () - > PyClassInitializer { PyClassInitializer :: from ( Base1 { name1 : " base1 " } ) . add_subclass ( Base2 { name2 : " base2 " } ) . add_subclass ( Self { name3 : " sub " } ) } fn name ( slf : PyRef ) - > String { let subname = slf . name3 ; let super_ = slf . into_super () ; format! ( " {} {} {} " super_ . as_ref () . name1 super_ . name2 subname ) } }
python::with_gil(|py| {
None
let sub = pycell::new(py, sub::new()).unwrap();
None
pyo3::py_run!(py, sub, "assert sub.name() == 'base1 base2 sub'")
None
});
None