Rust:
fn main() { loop { } }
Or, for a slightly more involved example:
use std::num::Wrapping; use std::iter::Iterator; struct Fibs { n: Wrapping<usize>, n_minus_one: Wrapping<usize>, } impl Fibs { fn new() -> Self { Fibs { n: Wrapping(1), n_minus_one: Wrapping(0), } } } impl Iterator for Fibs { type Item = Wrapping<usize>; fn next(&mut self) -> Option<Self::Item> { let n_plus_one = self.n + self.n_minus_one; self.n_minus_one = self.n; self.n = n_plus_one; Some(n_plus_one) } } fn main() { let mut fibs = Fibs::new(); while let Some(n) = fibs.next() { println!("{}", n); } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Rust:
Or, for a slightly more involved example: