add max value from iterator

This commit is contained in:
Matthew Piziak 2016-11-02 10:11:53 -04:00
parent dd6e8c5f18
commit 8f19d5c3f6
2 changed files with 4 additions and 0 deletions

View File

@ -15,12 +15,14 @@ use std::panic;
fn main() {
let r = panic::catch_unwind(|| {
let mut it = u8::max_value()..;
it.next().unwrap(); // 255
it.next().unwrap();
});
assert!(r.is_err());
let r = panic::catch_unwind(|| {
let mut it = i8::max_value()..;
it.next().unwrap(); // 127
it.next().unwrap();
});
assert!(r.is_err());

View File

@ -12,8 +12,10 @@
fn main() {
let mut it = u8::max_value()..;
assert_eq!(it.next().unwrap(), 255);
assert_eq!(it.next().unwrap(), u8::min_value());
let mut it = i8::max_value()..;
assert_eq!(it.next().unwrap(), 127);
assert_eq!(it.next().unwrap(), i8::min_value());
}