default.txt 933 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. use std;
  2. #![warn(unstable)]
  3. /* Factorial */
  4. fn fac(n: int) -> int {
  5. let s: str = "This is
  6. a multi-line string.
  7. It ends with an unescaped '\"'.";
  8. let c: char = 'Ф';
  9. let r: str = r##" raw string "##;
  10. let result = 1, i = 1;
  11. while i <= n { // No parens around the condition
  12. result *= i;
  13. i += 1;
  14. }
  15. ret result;
  16. }
  17. pure fn pure_length<T>(ls: list<T>) -> uint { /* ... */ }
  18. type t = map::hashtbl<int,str>;
  19. let x = id::<int>(10);
  20. // Define some modules.
  21. #[path = "foo.rs"]
  22. mod foo;
  23. impl <T> Seq<T> for [T] {
  24. fn len() -> uint { vec::len(self) }
  25. fn iter(b: fn(T)) {
  26. for elt in self { b(elt); }
  27. }
  28. }
  29. enum list<T> {
  30. Nil;
  31. Cons(T, @list<T>);
  32. }
  33. let a: list<int> = Cons(7, @cons(13, @nil));
  34. struct Baz<'a> {
  35. baz: &'a str,
  36. }
  37. 'h: for i in range(0,10) {
  38. 'g: loop {
  39. if i % 2 == 0 { continue 'h; }
  40. if i == 9 { break 'h; }
  41. break 'g;
  42. }
  43. }