mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
Simplify str::to_managed
This commit is contained in:
parent
a7ecde3323
commit
ac50046a11
@ -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…
Reference in New Issue
Block a user