Deprecated String::from_raw_parts

Replaced by `string::raw::from_parts`

[breaking-change]
This commit is contained in:
Adolfo Ochagavía 2014-07-21 20:44:56 +02:00 committed by Alex Crichton
parent 6e509d3462
commit 0fe894e49b
2 changed files with 21 additions and 9 deletions

View File

@ -558,7 +558,8 @@ pub mod raw {
use core::mem; use core::mem;
use core::raw::Slice; use core::raw::Slice;
use core::ptr::RawPtr; use core::ptr::RawPtr;
use string::{mod, String}; use string;
use string::String;
use vec::Vec; use vec::Vec;
use MutableSeq; use MutableSeq;

View File

@ -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. /// Creates a new string buffer from the given string.
#[inline] #[inline]
pub fn from_str(string: &str) -> String { 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)] #[allow(missing_doc)]
#[deprecated = "obsoleted by the removal of ~str"] #[deprecated = "obsoleted by the removal of ~str"]
#[inline] #[inline]
@ -577,6 +576,18 @@ pub mod raw {
use super::String; use super::String;
use vec::Vec; 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 /// Converts a vector of bytes to a new `String` without checking if
/// it contains valid UTF-8. This is unsafe because it assumes that /// it contains valid UTF-8. This is unsafe because it assumes that
/// the utf-8-ness of the vector has already been validated. /// the utf-8-ness of the vector has already been validated.