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

12 lines
270 B
Rust
Raw Normal View History

2011-07-27 07:19:39 -05:00
pred even(x: uint) -> bool {
if x < 2u {
ret false;
} else if x == 2u { ret true; } else { ret even(x - 2u); }
}
2011-07-27 07:48:34 -05:00
fn print_even(x: uint) : even(x) { log 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); }