add max value from iterator
This commit is contained in:
parent
dd6e8c5f18
commit
8f19d5c3f6
2 changed files with 4 additions and 0 deletions
|
@ -15,12 +15,14 @@ use std::panic;
|
||||||
fn main() {
|
fn main() {
|
||||||
let r = panic::catch_unwind(|| {
|
let r = panic::catch_unwind(|| {
|
||||||
let mut it = u8::max_value()..;
|
let mut it = u8::max_value()..;
|
||||||
|
it.next().unwrap(); // 255
|
||||||
it.next().unwrap();
|
it.next().unwrap();
|
||||||
});
|
});
|
||||||
assert!(r.is_err());
|
assert!(r.is_err());
|
||||||
|
|
||||||
let r = panic::catch_unwind(|| {
|
let r = panic::catch_unwind(|| {
|
||||||
let mut it = i8::max_value()..;
|
let mut it = i8::max_value()..;
|
||||||
|
it.next().unwrap(); // 127
|
||||||
it.next().unwrap();
|
it.next().unwrap();
|
||||||
});
|
});
|
||||||
assert!(r.is_err());
|
assert!(r.is_err());
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut it = u8::max_value()..;
|
let mut it = u8::max_value()..;
|
||||||
|
assert_eq!(it.next().unwrap(), 255);
|
||||||
assert_eq!(it.next().unwrap(), u8::min_value());
|
assert_eq!(it.next().unwrap(), u8::min_value());
|
||||||
|
|
||||||
let mut it = i8::max_value()..;
|
let mut it = i8::max_value()..;
|
||||||
|
assert_eq!(it.next().unwrap(), 127);
|
||||||
assert_eq!(it.next().unwrap(), i8::min_value());
|
assert_eq!(it.next().unwrap(), i8::min_value());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue