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
|
|
@ -559,7 +559,7 @@ pub mod raw {
|
|||
use core::raw::Slice;
|
||||
use core::ptr::RawPtr;
|
||||
|
||||
use string::String;
|
||||
use string::{mod, String};
|
||||
use vec::Vec;
|
||||
|
||||
use MutableSeq;
|
||||
|
|
@ -592,11 +592,10 @@ pub mod raw {
|
|||
buf
|
||||
}
|
||||
|
||||
/// Converts an owned vector of bytes to a new owned string. This assumes
|
||||
/// that the utf-8-ness of the vector has already been validated
|
||||
#[inline]
|
||||
/// Deprecated. Replaced by `string::raw::from_utf8`
|
||||
#[deprecated = "Use string::raw::from_utf8"]
|
||||
pub unsafe fn from_utf8_owned(v: Vec<u8>) -> String {
|
||||
mem::transmute(v)
|
||||
string::raw::from_utf8(v)
|
||||
}
|
||||
|
||||
/// Converts a byte to a string.
|
||||
|
|
|
|||
|
|
@ -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::*;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
// ignore-lexer-test FIXME #15679
|
||||
|
||||
//! Base64 binary-to-text encoding
|
||||
use std::str;
|
||||
use std::fmt;
|
||||
use std::string;
|
||||
|
||||
/// Available encoding character sets
|
||||
pub enum CharacterSet {
|
||||
|
|
@ -148,7 +148,7 @@ impl<'a> ToBase64 for &'a [u8] {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
str::raw::from_utf8_owned(v)
|
||||
string::raw::from_utf8(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
// ignore-lexer-test FIXME #15679
|
||||
|
||||
//! Hex binary-to-text encoding
|
||||
use std::str;
|
||||
use std::fmt;
|
||||
use std::string;
|
||||
|
||||
/// A trait for converting a value to hexadecimal encoding
|
||||
pub trait ToHex {
|
||||
|
|
@ -47,7 +47,7 @@ impl<'a> ToHex for &'a [u8] {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
str::raw::from_utf8_owned(v)
|
||||
string::raw::from_utf8(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue