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 23:58:00 +00:00
2015-01-02 15:25:54 +00:00
trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
2014-11-02 23:58:00 +00:00
2014-12-06 02:12:25 +00:00
impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
fn iter(&'r self) -> Range<usize> {
2014-11-02 23:58:00 +00:00
let &(min, max) = self;
min..max
2014-11-02 23:58:00 +00:00
}
}
2014-12-06 02:12:25 +00:00
fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
2014-11-02 23:58:00 +00:00
{
let cont_iter = cont.iter();
2018-12-25 15:56:47 +00:00
//~^ ERROR explicit lifetime required in the type of `cont` [E0621]
let result = cont_iter.fold(Some(0), |state, val| {
2014-11-02 23:58:00 +00: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 23:58:00 +00:00
}