class!() { /* proc-macro */ }
Expand description
Defines a class.
§Syntax
ⓘ
use oop_inheritance::Node;
class! {
struct MyClass: SuperClass1 < SuperClassN < Node {
// fn x() -> f64
// fn set_x(x: f64) -> Self
x: f64 = 0.0,
// fn y() -> Arc<f64>
// fn set_y(y: Arc<f64>) -> Self
ref y: f64 = 0.0,
}
// fn new() -> Self
fn constructor() {
super();
}
}
§Topmost super class
The topmost super class of a class defined by class!
must be oop_inheritance::Node
; otherwise it is undefined behavior.
§Reference parameter
If it is desired to receive a parameter as a specific class
or any subclass, take a parameter implementing AsRef<C>
:
ⓘ
fn my_function(object: impl AsRef<MyClass>) {
let object = object.as_ref();
// object: &MyClass
}