rust/tests/ui/issues/issue-13058.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
694 B
Rust
Raw Normal View History

use std::ops::Range;
2014-11-02 17:58:00 -06:00
2015-01-02 09:25:54 -06:00
trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
2014-11-02 17:58:00 -06:00
2014-12-05 20:12:25 -06:00
impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
fn iter(&'r self) -> Range<usize> {
2014-11-02 17:58:00 -06:00
let &(min, max) = self;
min..max
2014-11-02 17:58:00 -06:00
}
}
2014-12-05 20:12:25 -06:00
fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
2014-11-02 17:58:00 -06:00
{
let cont_iter = cont.iter();
2018-12-25 09:56:47 -06:00
//~^ ERROR explicit lifetime required in the type of `cont` [E0621]
let result = cont_iter.fold(Some(0), |state, val| {
2014-11-02 17:58:00 -06:00
state.map_or(None, |mask| {
let bit = 1 << val;
if mask & bit == 0 {Some(mask|bit)} else {None}
})
});
result.is_some()
}
fn main() {
check(&(3, 5));
2014-11-02 17:58:00 -06:00
}