Simplify str::to_managed
This commit is contained in:
parent
a7ecde3323
commit
ac50046a11
1 changed files with 2 additions and 3 deletions
|
@ -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) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue