/src/test/run-pass/alt-join.rs

http://github.com/jruderman/rust · Rust · 22 lines · 16 code · 4 blank · 2 comment · 3 complexity · e8085bea7971eab85830db5bdf426791 MD5 · raw file

  1. use std;
  2. import option;
  3. fn foo<T>(y: option<T>) {
  4. let mut x: int;
  5. let mut rs: ~[int] = ~[];
  6. /* tests that x doesn't get put in the precondition for the
  7. entire if expression */
  8. if true {
  9. } else {
  10. match y {
  11. none::<T> => x = 17,
  12. _ => x = 42
  13. }
  14. rs += ~[x];
  15. }
  16. return;
  17. }
  18. fn main() { debug!{"hello"}; foo::<int>(some::<int>(5)); }