diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-07-27 14:48:34 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-07-27 15:54:33 +0200 |
| commit | 6e2a7bff7faf040b1eced0ee3547b28f6962cedc (patch) | |
| tree | bd05a425b4ad236d7e861ffdf0931bf71ad3bba9 /src/lib | |
| parent | df7f21db093b0f206048b18e977161f91b7c28f1 (diff) | |
Fix damage done by the pretty-printer
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/extfmt.rs | 18 | ||||
| -rw-r--r-- | src/lib/ivec.rs | 6 | ||||
| -rw-r--r-- | src/lib/str.rs | 4 | ||||
| -rw-r--r-- | src/lib/test.rs | 2 |
4 files changed, 14 insertions, 16 deletions
diff --git a/src/lib/extfmt.rs b/src/lib/extfmt.rs index 00302ea9e26..f9db8eda693 100644 --- a/src/lib/extfmt.rs +++ b/src/lib/extfmt.rs @@ -215,11 +215,9 @@ mod ct { {ty: ty, next: uint} { if i >= lim { error("missing type in conversion"); } let tstr = str::substr(s, i, 1u); - let - - // TODO: Do we really want two signed types here? - // How important is it to be printf compatible? - t = + // TODO: Do we really want two signed types here? + // How important is it to be printf compatible? + let t = if str::eq(tstr, "b") { ty_bool } else if (str::eq(tstr, "s")) { @@ -305,13 +303,11 @@ mod rt { ret pad(cv, str::from_char(c), pad_nozero); } fn conv_str(cv: &conv, s: str) -> str { - let - - // For strings, precision is the maximum characters - // displayed + // For strings, precision is the maximum characters + // displayed - // FIXME: substr works on bytes, not chars! - unpadded = + // FIXME: substr works on bytes, not chars! + let unpadded = alt cv.precision { count_implied. { s } count_is(max) { diff --git a/src/lib/ivec.rs b/src/lib/ivec.rs index 71dc9cf7a65..c710d220a6b 100644 --- a/src/lib/ivec.rs +++ b/src/lib/ivec.rs @@ -90,10 +90,12 @@ pred is_not_empty[T](v: &T[mutable? ]) -> bool { ret !is_empty(v); } // Accessors /// Returns the first element of a vector -fn head[T](v: &T[mutable? ]) -> T { ret v.(0); } +fn head[T](v: &T[mutable?]) : is_not_empty(v) -> T { ret v.(0); } /// Returns all but the first element of a vector -fn tail[T](v: &T[mutable? ]) -> T[mutable? ] { ret slice(v, 1u, len(v)); } +fn tail[T](v: &T[mutable? ]) : is_not_empty(v) -> T[mutable?] { + ret slice(v, 1u, len(v)); +} /// Returns the last element of `v`. fn last[T](v: &T[mutable? ]) -> option::t[T] { diff --git a/src/lib/str.rs b/src/lib/str.rs index ca0a81add80..0adf3561165 100644 --- a/src/lib/str.rs +++ b/src/lib/str.rs @@ -396,7 +396,7 @@ fn slice(s: str, begin: uint, end: uint) -> str { ret rustrt::str_slice(s, begin, end); } -fn safe_slice(s: str, begin: uint, end: uint) -> str { +fn safe_slice(s: str, begin: uint, end: uint): le(begin, end) -> str { assert (end <= str::byte_len(s)); // would need some magic to // make this a precondition @@ -505,7 +505,7 @@ fn to_upper(s: str) -> str { } // FIXME: This is super-inefficient -fn replace(s: str, from: str, to: str) -> str { +fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str { // FIXME (694): Shouldn't have to check this check (is_not_empty(from)); if byte_len(s) == 0u { diff --git a/src/lib/test.rs b/src/lib/test.rs index 801d7cff073..03606debc1d 100644 --- a/src/lib/test.rs +++ b/src/lib/test.rs @@ -58,7 +58,7 @@ type test_opts = {filter: option::t[str], run_ignored: bool}; type opt_res = either::t[test_opts, str]; // Parses command line arguments into test options -fn parse_opts(args: &str[]) -> opt_res { +fn parse_opts(args: &str[]) : ivec::is_not_empty(args) -> opt_res { // FIXME (#649): Shouldn't have to check here check (ivec::is_not_empty(args)); |
