Skip to content

Commit ac50046

Browse files
committed
Simplify str::to_managed
1 parent a7ecde3 commit ac50046

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libcore/str.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,9 +2262,8 @@ impl &str: StrSlice {
22622262

22632263
#[inline]
22642264
pure fn to_managed() -> @str {
2265-
let v = at_vec::from_fn(self.len() + 1, |i| {
2266-
if i == self.len() { 0 } else { self[i] }
2267-
});
2265+
let bytes = as_bytes_slice(self);
2266+
let v = at_vec::from_fn(bytes.len(), |i| bytes[i]);
22682267
unsafe { ::cast::transmute(v) }
22692268
}
22702269

0 commit comments

Comments
 (0)