diff options
| author | Roy Frostig <[email protected]> | 2010-08-04 23:09:25 -0700 |
|---|---|---|
| committer | Roy Frostig <[email protected]> | 2010-08-04 23:09:33 -0700 |
| commit | 718c0b5963e6513337e4fee003b34423397c2d14 (patch) | |
| tree | bfce28f0d0e3b523691c4b536af213330a0f0a96 /src/lib/_str.rs | |
| parent | Thread argument-types down to internal_check_outer_lval in type.ml, in prepar... (diff) | |
| download | rust-718c0b5963e6513337e4fee003b34423397c2d14.tar.xz rust-718c0b5963e6513337e4fee003b34423397c2d14.zip | |
Add to std._io some formatter/type-specific-writer mechanism. Make a few type-specific buffered writers as wrappers of buf_writer.
Diffstat (limited to 'src/lib/_str.rs')
| -rw-r--r-- | src/lib/_str.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs index 062d8bf1..8eed9a38 100644 --- a/src/lib/_str.rs +++ b/src/lib/_str.rs @@ -12,6 +12,18 @@ fn is_utf8(vec[u8] v) -> bool { fail; // FIXME } +fn is_ascii(str s) -> bool { + let uint i = len(s); + while (i > 0u) { + i -= 1u; + // FIXME (issue #94) + if ((s.(i as int) & 0x80u8) != 0u8) { + ret false; + } + } + ret true; +} + fn alloc(uint n_bytes) -> str { ret rustrt.str_alloc(n_bytes); } @@ -23,3 +35,10 @@ fn len(str s) -> uint { fn buf(str s) -> sbuf { ret rustrt.str_buf(s); } + +fn bytes(&str s) -> vec[u8] { + fn ith(str s, uint i) -> u8 { + ret s.(i as int); // FIXME (issue #94) + } + ret _vec.init_fn[u8](bind ith(s, _), _str.len(s)); +} |