Hi! I'm implementing a range type which has multiple ranges, for which I wanted to impl RangeBounds
(in second thought this may be not needed)..
In any case, while trying to implement a proper fn contains()
, I found this error which I don't think it should happen as all types involved in the expression are usize
:
struct Foo {
r: Vec<usize>,
}
impl Foo {
fn contains<U>(&self, item: &U) -> bool
where
usize: PartialOrd<U>,
U: ?Sized + PartialOrd<usize>,
{
if self.r.is_empty() {
return false;
}
if let Some(pos) = self.r.iter().position(|v| v < item) {
(pos % 2) == 0 // error
} else {
false
}
}
}
I get error E0308 in line 15.
If I put the offending expression in a new function and using it, the code compiles fine...
Is this error OK?