fork download
  1. use std::io::stdin;
  2. use std::io::BufRead;
  3. use std::io::BufReader;
  4.  
  5. fn main()
  6. {
  7. println!("ISO, nya:{}", take(1000));
  8. println!("filter :{}", filter(1000));
  9. }
  10.  
  11. pub fn take(end: u32) -> u32 {
  12. (0..).step_by(1000000000)
  13. .map(|i| i * i)
  14. .take_while(|&i| i < end)
  15. .sum()
  16. }
  17. pub fn filter(end: u32) -> u32 {
  18. (0..).step_by(1000000000)
  19. .map(|i| i * i)
  20. .filter(|&i| i < end)
  21. .sum()
  22. }
Runtime error #stdin #stdout #stderr 0.01s 5296KB
stdin
Standard input is empty
stdout
ISO, nya:0
stderr
thread 'main' panicked at 'overflow in RangeFrom::nth', src/libcore/option.rs:1038:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.