Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Created March 17, 2016 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nixpulvis/78bbe97e00a9d1ed5c11 to your computer and use it in GitHub Desktop.
Save nixpulvis/78bbe97e00a9d1ed5c11 to your computer and use it in GitHub Desktop.
#[derive(Debug)]
struct Recur(u32);
impl Recur {
pub fn call(n: u32) -> u32 {
let r = Recur(n);
let r = r.recur();
r.0
}
fn recur(mut self) -> Self {
println!("{:?}", self);
if self.0 == 0 {
self
} else {
self.0 -= 1;
self.recur()
}
}
}
fn main() {
Recur::call(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment