I'm trying to set up a tree structure in Rust, but I've run into an issue with how to store the list of nodes, which store different types of values, and therefore have different type parameters.
A simplified version of the problem is below:
struct Node<T> {
pub props: T,
pub children: Vec<Node>
}
fn main() {
let node = Node {
props: (42, 6),
children: vec![Node {
props: Some("potatoes"),
children: vec![]
}]
};
}
This fails to compile with the following error:
error[E0243]: wrong number of type arguments: expected 1, found 0
--> src/main.rs:4:19
|
4 | children: Vec<Node>
| ^^^^ expected 1 type argument
I can't provide a type argument, since it must be allowed to be anything. What's the best way to go about doing this?
I've looked at this question, but it doesn't address type arguments.