Deprecated str::raw::from_utf8_owned
Replaced by `string::raw::from_utf8` [breaking-change]
This commit is contained in:
parent
eacc5d779f
commit
9ec19373af
4 changed files with 21 additions and 9 deletions
|
|
@ -570,6 +570,19 @@ impl<S: Str> Add<S, String> for String {
|
|||
}
|
||||
}
|
||||
|
||||
pub mod raw {
|
||||
use super::String;
|
||||
use vec::Vec;
|
||||
|
||||
/// Converts a vector of bytes to a new `String` without checking if
|
||||
/// it contains valid UTF-8. This is unsafe because it assumes that
|
||||
/// the utf-8-ness of the vector has already been validated.
|
||||
#[inline]
|
||||
pub unsafe fn from_utf8(bytes: Vec<u8>) -> String {
|
||||
String { vec: bytes }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue