aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/_str.rs8
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;