Very confuse problem about generic, please Help

I meet another problem about generic, code as following

enum DTNodeVaule<T, U, F: Fn(T)-> usize> {
    Finished(U),
    Classfy(F),
}

compile error again:

parameter `T` is never used

unused parameter

help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`rustc(E0392)

I met a similar problem a few day ago, but that time is a struct.
this time is about enum
neither associated type nor marker::phantomdata is not works
how can I do, please help, thanks

PhantomData does work. Below I've added it to the Classify variant as that's the variant that uses T.

use std::marker::PhantomData;

enum DTNodeValue<T, U, F: Fn(T)-> usize> {
    Finished(U),
    Classify(F, PhantomData<T>),
}

fn example(b: bool) {
    let example = match b {
        true  => DTNodeValue::Classify(Vec::len, PhantomData::<&Vec<f64>>),
        false => DTNodeValue::Finished('f'),
    };
}

Here's a recent similar thread with some other suggestions.

Yes, It does work, thank you :slight_smile:

Though in this case you're using T in a negative position, so you'd probably want:

enum DTNodeValue<T, U, F: Fn(T)-> usize> {
    Finished(U),
    Classify(F, PhantomData<fn(T)>),
}