Deprecated String::from_raw_parts
Replaced by `string::raw::from_parts` [breaking-change]
This commit is contained in:
parent
6e509d3462
commit
0fe894e49b
@ -558,7 +558,8 @@ pub mod raw {
|
||||
use core::mem;
|
||||
use core::raw::Slice;
|
||||
use core::ptr::RawPtr;
|
||||
use string::{mod, String};
|
||||
use string;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
use MutableSeq;
|
||||
|
@ -49,14 +49,6 @@ pub fn with_capacity(capacity: uint) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new string buffer from length, capacity, and a pointer.
|
||||
#[inline]
|
||||
pub unsafe fn from_raw_parts(length: uint, capacity: uint, ptr: *mut u8) -> String {
|
||||
String {
|
||||
vec: Vec::from_raw_parts(length, capacity, ptr),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new string buffer from the given string.
|
||||
#[inline]
|
||||
pub fn from_str(string: &str) -> String {
|
||||
@ -65,6 +57,13 @@ pub fn from_str(string: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Deprecated. Replaced by `string::raw::from_parts`
|
||||
#[inline]
|
||||
#[deprecated = "Replaced by string::raw::from_parts"]
|
||||
pub unsafe fn from_raw_parts(length: uint, capacity: uint, ptr: *mut u8) -> String {
|
||||
raw::from_parts(length, capacity, ptr)
|
||||
}
|
||||
|
||||
#[allow(missing_doc)]
|
||||
#[deprecated = "obsoleted by the removal of ~str"]
|
||||
#[inline]
|
||||
@ -577,6 +576,18 @@ pub mod raw {
|
||||
use super::String;
|
||||
use vec::Vec;
|
||||
|
||||
/// Creates a new `String` from length, capacity, and a pointer.
|
||||
///
|
||||
/// This is unsafe because:
|
||||
/// * We call `Vec::from_raw_parts` to get a `Vec<u8>`
|
||||
/// * We assume that the `Vec` contains valid UTF-8
|
||||
#[inline]
|
||||
pub unsafe fn from_parts(length: uint, capacity: uint, ptr: *mut u8) -> String {
|
||||
String {
|
||||
vec: Vec::from_raw_parts(length, capacity, ptr),
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
Loading…
Reference in New Issue
Block a user