rust/src/test/run-pass/if-check-precond.rs

12 lines
281 B
Rust
Raw Normal View History

pure fn even(x: uint) -> bool {
2011-07-27 07:19:39 -05:00
if x < 2u {
ret false;
} else if x == 2u { ret true; } else { ret even(x - 2u); }
}
fn print_even(x: uint) : even(x) { log(debug, x); }
2011-07-27 07:19:39 -05:00
fn foo(x: uint) { if check even(x) { print_even(x); } else { fail; } }
fn main() { foo(2u); }