pub fn add_subclass<S>(self, subclass_value: S) -> PyClassInitializer<S>
    where
        S: PyClass<BaseType = T>,
        S::BaseType: PyClassBaseType<Initializer = Self>,
    {
        PyClassInitializer::new(subclass_value, self)
    }
/// Constructs a new initializer from an initializer for the base class.
///
/// # Examples
/// ```
/// use pyo3::prelude::*;
///
/// #[pyclass(subclass)]
/// struct BaseClass {
///     #[pyo3(get)]
///     value: i32,
/// }
///
/// impl BaseClass {
///     fn new(value: i32) -> PyResult<Self> {
///         Ok(Self { value })
///     }
/// }
///
/// #[pyclass(extends=BaseClass)]
/// struct SubClass {}
///
/// #[pymethods]
/// impl SubClass {
///     #[new]
///     fn new(value: i32) -> PyResult<PyClassInitializer<Self>> {
///         let base_init = PyClassInitializer::from(BaseClass::new(value)?);
///         Ok(base_init.add_subclass(SubClass {}))
///     }
/// }
///
/// fn main() -> PyResult<()> {
///     Python::with_gil(|py| {
///         let m = PyModule::new(py, "example")?;
///         m.add_class::<SubClass>()?;
///         m.add_class::<BaseClass>()?;
///
///         let instance = m.getattr("SubClass")?.call1((92,))?;
///
///         // `SubClass` does not have a `value` attribute, but `BaseClass` does.
///         let n = instance.getattr("value")?.extract::<i32>()?;
///         assert_eq!(n, 92);
///
///         Ok(())
///     })
/// }
/// ```
Constructs a new initializer from an initializer for the base class.
Constructs a new initializer from an initializer for the base class .
pub fn add_subclass<S>(self, subclass_value: S) -> PyClassInitializer<S>
    where
        S: PyClass<BaseType = T>,
        S::BaseType: PyClassBaseType<Initializer = Self>,
    {
        PyClassInitializer::new(subclass_value, self)
    }
pub fn add_subclass < S > ( self , subclass_value : S ) -> PyClassInitializer < S > where S : PyClass < BaseType = T > , S :: BaseType : PyClassBaseType < Initializer = Self > , { PyClassInitializer :: new ( subclass_value , self ) }
Constructs a new initializer from an initializer for the base class.
Constructs a new initializer from an initializer for the base class .
self
subclass_value
S
examples
None
[pyclass(subclass)]
struct BaseClass {
[pyo3(get)]
value: i32,
}

impl BaseClass {
fn new(value: i32) -> PyResult {
Ok(Self { value })
}
}
struct BaseClass { [ pyo3 ( get ) ] value : i32 } impl BaseClass { fn new ( value : i32 ) - > PyResult { Ok ( Self { value } ) } }
[pyclass(extends=baseclass)]
struct SubClass {}
struct SubClass {}
[pymethods]
impl SubClass {
[new]
fn new(value: i32) -> PyResult> {
let base_init = PyClassInitializer::from(BaseClass::new(value)?);
Ok(base_init.add_subclass(SubClass {}))
}
}





`SubClass` does not have a `value` attribute, but `BaseClass` does.


impl SubClass { [ new ] fn new ( value : i32 ) - > PyResult > { let base_init = PyClassInitializer :: from ( BaseClass :: new ( value ) ? ) ; Ok ( base_init . add_subclass ( SubClass {} )) } } ` SubClass ` does not have a ` value ` attribute but ` BaseClass ` does .