Simplify str::to_managed

This commit is contained in:
Erick Tryzelaar 2012-10-18 11:04:32 -07:00
parent a7ecde3323
commit ac50046a11

View File

@ -2262,9 +2262,8 @@ impl &str: StrSlice {
#[inline]
pure fn to_managed() -> @str {
let v = at_vec::from_fn(self.len() + 1, |i| {
if i == self.len() { 0 } else { self[i] }
});
let bytes = as_bytes_slice(self);
let v = at_vec::from_fn(bytes.len(), |i| bytes[i]);
unsafe { ::cast::transmute(v) }
}