python_ast/datamodel/
class.rs

1//! traits for Python classes Objects. Classes are Object factories, meaning they create instances of objects.
2
3use crate::Object;
4
5/// The Class trait is used to define Python classes. Classes are Object factories, meaning they create instances of objects.
6pub trait Class: Object + Default {
7    type Super: Class + Into<Self>;
8
9    /// Returns the method resolution order of the class.
10    //fn mro(&self) -> Box<dyn Iterator<Item = Box<impl Class>>>;
11
12    /// __new__ returns an instance of the class. Because of Rust's requirement that all objects be initialized,
13    /// we require that the Object implement the Default trait. By default, we just return the default instance of the object.
14    fn __new__() -> Self {
15        Self::Super::__new__().into()
16    }
17
18    /// __init__ is called after __new__ and is used to initialize the object.
19    fn __init__<A>(&mut self, args: A) {}
20}