You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore\option.rs:362
I tried this code:
#![feature(iter_arith)]
fn main() {
println!("avg1 = {}", avg::<isize>( (1..11) ));
println!("avg1 = {}", avg::<isize>( (1..11).filter(|&x| x % 2 == 0) ));
}
fn avg<S, T=T::Item>(x: T) -> f64
where T: IntoIterator<Item=isize> {
let it = x.into_iter();
match it.size_hint() {
(lower, Some(upper)) if lower == upper => {
println!("exact len");
it.sum::<S>() as f64 / lower as f64
}
_ => {
let mut sum = 0;
let mut count = 0;
for i in it {
sum = sum + i;
count += 1;
}
sum as f64 / count as f64
}
}
}
I expected to see this happen: code should compile or the compiler should report an error.
I tried this code:
I expected to see this happen: code should compile or the compiler should report an error.
Instead, this happened: the compiler panicked.
Meta
rustc --version --verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: