So to be short this is how my current solution for some sort of inheritance goes in rust for a problem I need to solve
pub struct NodeBase{
id: usize,
dims: [SymPolynomial; 2]
name: String,
children: Vec<usize>,
gradient_level: u8,
inline: bool,
}
pub struct NumberNode{
base: NodeBase,
value: f64
}
pub struct ConstInputNode{
base: NodeBase,
}
pub struct ParameterNode {
base: NodeBase,
grad_child: usize,
}
pub struct ConstDerivedNode{
base: NodeBase,
op: Operator
}
pub struct ParameterDerivedNode{
base: NodeBase,
op: Operator,
grad_child: usize,
grad_parent: usize
}
enum ComputeNode{
Number(NumberNode),
ConstInput(ConstInputNode),
Parameter(ParameterNode),
ConstDerived(ConstDerivedNode),
ParameterDerived(ParameterDerivedNode)
}
Now I'm well aware there is a significant discussion about resolving this and the "Efficient code reuse" challenge with several RFCs already. Just wondering what is the "best practice" current suggestion for such situation? Is my code okay or is that really bad? Just want to educate myself on the topic.