Created
March 17, 2016 06:04
-
-
Save nixpulvis/78bbe97e00a9d1ed5c11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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