Consider the following (very cut down) code. It will not compile, on the self.is_x()
call with "cannot infer type for type parameter S
declared on the trait Refiner
". I'm not completely sure what the problem is, and I'm also not sure how to fix it -- how can I "type annotate" self?
pub trait Refiner<S> {
fn name(&self) -> usize;
fn is_x(&self) -> bool;
}
pub struct Q { }
impl<T> Refiner<T> for Q {
fn name(&self) -> usize {
if self.is_x() { 2 } else { 3 }
}
fn is_x(&self) -> bool {
true
}
}