Note this bit: impl<A: Step> Iterator for ops::RangeInclusive<A> {
RangeInclusive<A> implements Iterator only for types A which implement Step. Floating point types like f64 are not Step:https://doc.rust-lang.org/std/iter/trait.Step.html Thus RangeInclusive<f64> is perfectly valid, but RangeInclusive<f64> cannot be used as an Iterator. See also the bounds on contains(): https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html... f64 is PartialOrd<f64>, so a RangeInclusive<f64> can be asked if it contains a specified f64. This definition would also allow one to ask a RangeInclusive<IpAddr> if it contains a specified IpAddr _or_ Ipv4Addr _or_ Ipv6Addr, since IpAddr is PartialOrd<IpAddr>, PartialOrd<Ipv4Addr>, and PartialOrd<Ipv6Addr>. Any type A which can be compared to any other type B automatically gets RangeInclusive<A>::contains(B). Anything which doesn't can still be a RangeInclusive<A>, it just won't have contains(). |