+ pub(crate) fn into_string(self) -> String {
+ let bytes = if self.len == 0 {
+ Vec::new()
+ } else if self.chars_is_owned {
+ unsafe {
+ Box::from_raw(std::slice::from_raw_parts_mut(unsafe { self.chars as *mut u8 }, self.len))
+ }.into()
+ } else {
+ let mut ret = Vec::with_capacity(self.len);
+ ret.extend_from_slice(unsafe { std::slice::from_raw_parts(self.chars, self.len) });
+ ret
+ };
+ String::from_utf8(bytes).unwrap()
+ }