Skip to content

Commit 45b614f

Browse files
committed
Add ivec::from_str and to_str methods. Issue #855
1 parent 663d07d commit 45b614f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/lib/istr.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ concat, connect, to_upper, replace, char_slice, trim_left, trim_right, trim,
44
unshift_char, shift_char, pop_char, push_char, is_utf8, from_chars, to_chars,
55
char_len, char_at, bytes, is_ascii, shift_byte, pop_byte;
66

7+
export from_str, to_str;
8+
9+
fn from_str(s: &str) -> istr {
10+
let s2 = ~"";
11+
for u in s {
12+
push_byte(s2, u);
13+
}
14+
ret s2;
15+
}
16+
17+
fn to_str(s: &istr) -> str {
18+
let s2 = "";
19+
for u in s {
20+
str::push_byte(s2, u);
21+
}
22+
ret s2;
23+
}
24+
725
fn eq(a: &istr, b: &istr) -> bool { a == b }
826

927
fn lteq(a: &istr, b: &istr) -> bool { a <= b }

0 commit comments

Comments
 (0)