Skip to content

Commit 706fd60

Browse files
committed
---
yaml --- r: 4927 b: refs/heads/master c: b31815f h: refs/heads/master i: 4925: c856e26 4923: 15101eb 4919: 242e747 4911: 86e74db 4895: 86c9fe5 4863: 9cf28fa v: v3
1 parent 5299eb0 commit 706fd60

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b371891c7c35f5d561a4847515e41014c652fa26
2+
refs/heads/master: b31815f8a0b98445d2a82888a290b9543ad4400f

trunk/src/lib/istr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export eq, lteq, hash, is_empty, is_not_empty, is_whitespace, byte_len,
22
index, rindex, find, starts_with, ends_with, substr, slice, split,
33
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,
5-
char_len, char_at, bytes, is_ascii, shift_byte, pop_byte;
5+
char_len, char_at, bytes, is_ascii, shift_byte, pop_byte, unsafe_from_bytes;
66

77
export from_str, to_str;
88

@@ -111,6 +111,7 @@ fn bytes(s: &istr) -> [u8] {
111111
fn unsafe_from_bytes(v: &[mutable? u8]) -> istr {
112112
let vcopy: [u8] = v + [0u8];
113113
let scopy: istr = unsafe::reinterpret_cast(vcopy);
114+
unsafe::leak(vcopy);
114115
ret scopy;
115116
}
116117

trunk/src/test/stdtest/istr.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,10 @@ fn pop_byte() {
249249
assert s == ~"AB";
250250
assert b == 67u8;
251251
}
252+
253+
#[test]
254+
fn unsafe_from_bytes() {
255+
let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8];
256+
let b = istr::unsafe_from_bytes(a);
257+
assert b == ~"AAAAAAA";
258+
}

0 commit comments

Comments
 (0)