diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2011-06-16 16:55:46 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-06-16 16:55:46 -0700 |
| commit | b84fffaa4e0e672b4653a7832d75a2dc120040aa (patch) | |
| tree | ad8e6854d11f6627b7afc9b8d14f525580beff55 /src/lib | |
| parent | eb9969f54699924e4373f6c447aaeb4dd041b0dd (diff) | |
| download | rust-b84fffaa4e0e672b4653a7832d75a2dc120040aa.tar.gz rust-b84fffaa4e0e672b4653a7832d75a2dc120040aa.zip | |
Reformat a bunch of recent churn.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/either.rs | 19 | ||||
| -rw-r--r-- | src/lib/fs.rs | 3 | ||||
| -rw-r--r-- | src/lib/list.rs | 12 | ||||
| -rw-r--r-- | src/lib/term.rs | 14 | ||||
| -rw-r--r-- | src/lib/util.rs | 3 |
5 files changed, 19 insertions, 32 deletions
diff --git a/src/lib/either.rs b/src/lib/either.rs index 12ccbb2bbfb..0af528d7e5f 100644 --- a/src/lib/either.rs +++ b/src/lib/either.rs @@ -1,17 +1,15 @@ + import option; import option::some; import option::none; -tag t[T, U] { - left(T); - right(U); -} +tag t[T, U] { left(T); right(U); } -type operator[T, U] = fn(&T) -> U; +type operator[T, U] = fn(&T) -> U ; -fn either[T, U, V](&operator[T, V] f_left, - &operator[U, V] f_right, - &t[T, U] value) -> V { +fn either[T, U, + V](&operator[T, V] f_left, &operator[U, V] f_right, &t[T, U] value) + -> V { alt (value) { case (left(?l)) { f_left(l) } case (right(?r)) { f_right(r) } @@ -23,7 +21,7 @@ fn lefts[T, U](&vec[t[T, U]] eithers) -> vec[T] { for (t[T, U] elt in eithers) { alt (elt) { case (left(?l)) { result += [l] } - case (_) { /* fallthrough */ } + case (_) {/* fallthrough */ } } } ret result; @@ -34,7 +32,7 @@ fn rights[T, U](&vec[t[T, U]] eithers) -> vec[U] { for (t[T, U] elt in eithers) { alt (elt) { case (right(?r)) { result += [r] } - case (_) { /* fallthrough */ } + case (_) {/* fallthrough */ } } } ret result; @@ -51,7 +49,6 @@ fn partition[T, U](&vec[t[T, U]] eithers) -> tup(vec[T], vec[U]) { } ret tup(lefts, rights); } - // // Local Variables: // mode: rust diff --git a/src/lib/fs.rs b/src/lib/fs.rs index fb609a86a95..8d5cd3a4c7b 100644 --- a/src/lib/fs.rs +++ b/src/lib/fs.rs @@ -33,7 +33,8 @@ fn basename(path p) -> path { fn connect(path pre, path post) -> path { auto len = str::byte_len(pre); ret if (pre.(len - 1u) == os_fs::path_sep as u8) { - // Trailing '/'? + + // Trailing '/'? pre + post } else { pre + path_sep() + post }; } diff --git a/src/lib/list.rs b/src/lib/list.rs index a752e005b5e..bcd440f1aa6 100644 --- a/src/lib/list.rs +++ b/src/lib/list.rs @@ -23,10 +23,7 @@ fn foldl[T, U](&list[T] ls_, &U u, fn(&T, &U) -> U f) -> U { auto ls = ls_; while (true) { alt (ls) { - case (cons(?hd, ?tl)) { - accum = f(hd, accum); - ls = *tl; - } + case (cons(?hd, ?tl)) { accum = f(hd, accum); ls = *tl; } case (nil) { break; } } } @@ -54,16 +51,13 @@ fn has[T](&list[T] ls_, &T elt) -> bool { while (true) { alt (ls) { case (cons(?hd, ?tl)) { - if (elt == hd) { - ret true; - } else { - ls = *tl; - } + if (elt == hd) { ret true; } else { ls = *tl; } } case (nil) { ret false; } } } ret false; // Typestate checker doesn't understand infinite loops + } fn length[T](&list[T] ls) -> uint { diff --git a/src/lib/term.rs b/src/lib/term.rs index 14fddb55633..a4e723bac4f 100644 --- a/src/lib/term.rs +++ b/src/lib/term.rs @@ -48,17 +48,11 @@ fn reset(io::buf_writer writer) { } fn color_supported() -> bool { - auto supported_terms = ["xterm-color", - "xterm", - "screen-bce"]; + auto supported_terms = ["xterm-color", "xterm", "screen-bce"]; ret alt (generic_os::getenv("TERM")) { - case (option::some(?env)) { - vec::member(env, supported_terms) - } - case (option::none) { - false - } - }; + case (option::some(?env)) { vec::member(env, supported_terms) } + case (option::none) { false } + }; } fn set_color(io::buf_writer writer, u8 first_char, u8 color) { diff --git a/src/lib/util.rs b/src/lib/util.rs index 006982c34a3..19bd5923630 100644 --- a/src/lib/util.rs +++ b/src/lib/util.rs @@ -7,7 +7,8 @@ fn id[T](&T x) -> T { ret x; } * the constraint once fixed. */ type rational = rec(int num, int den); - // : int::positive(*.den); + +// : int::positive(*.den); fn rational_leq(&rational x, &rational y) -> bool { // NB: Uses the fact that rationals have positive denominators WLOG: |
