diff options
| author | Graydon Hoare <[email protected]> | 2011-04-26 20:39:33 +0000 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-26 20:39:33 +0000 |
| commit | bc6e9815379e31ac42b4d9fd2b0e20f708c1cc1c (patch) | |
| tree | f9ccd0dac288b2751536a6e552ec8e094e2a6739 /src/lib/_str.rs | |
| parent | Various bits of trans lint, nothing major. (diff) | |
| parent | rustc: Cap ridiculous type name sizes (diff) | |
| download | rust-bc6e9815379e31ac42b4d9fd2b0e20f708c1cc1c.tar.xz rust-bc6e9815379e31ac42b4d9fd2b0e20f708c1cc1c.zip | |
Merge branch 'master' of ssh://github.com/graydon/rust
Diffstat (limited to 'src/lib/_str.rs')
| -rw-r--r-- | src/lib/_str.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs index 3922acb6..41a86cf3 100644 --- a/src/lib/_str.rs +++ b/src/lib/_str.rs @@ -391,10 +391,14 @@ fn ends_with(str haystack, str needle) -> bool { } fn substr(str s, uint begin, uint len) -> str { + ret slice(s, begin, begin + len); +} + +fn slice(str s, uint begin, uint end) -> str { let str accum = ""; let uint i = begin; - while (i < begin+len) { - accum += unsafe_from_byte(s.(i)); + while (i < end) { + push_byte(accum, s.(i)); i += 1u; } ret accum; |