I am trying to implement Octree in Rust. Octree is generic in type with the restriction that it should implement a generic attribute:
pub trait Generable<U> { fn generate_children(&self, data: &U) -> Vec<Option<Self>>; } pub enum Octree<T, U> where T: Generable<U>, { Node { data: T, children: Vec<Box<Octree<T, U>>>, }, Empty, Uninitialized, }
Here is a simplified example reproducing a problem on a playground
This creates an error:
error[E0392]: parameter `U` is never used --> src/main.rs:5:20 | 5 | pub enum Octree<T, U> | ^ unused type parameter | = help: consider removing `U` or using a marker such as `std::marker::PhantomData`
Removing U from the signature result means "undeclared name of type" U ".
Am I doing something wrong or is it a mistake? How to do it right?
rust
ebvalaim Aug 17 '15 at 14:47 2015-08-17 14:47
source share