I don’t believe you want another generic here, you want an associated type:
pub trait Generable {
type From;
fn generate_children(&self, data: &Self::From) -> Vec<Option<Self>>
where
Self: Sized;
}
pub enum Octree<T>
where
T: Generable,
{
Node {
data: T,
children: Vec<Box<Octree<T>>>,
},
Empty,
Uninitialized,
}
fn main() {}
As an aside, Vec<Box<Octree<T>>>
is probably one level extra of indirection — you can just use Vec<Octree<T>>
.