about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-07-21 20:44:56 +0200
committerAlex Crichton <alex@alexcrichton.com>2014-07-24 07:25:43 -0700
commit0fe894e49be235ff0ac22231d7fa3579a4192f0a (patch)
treea79643e1374bffaeee99d386d80372a7d8ab2652
parent6e509d3462d20b696a1b5d18f14884b4e391a6ba (diff)
downloadrust-0fe894e49be235ff0ac22231d7fa3579a4192f0a.tar.gz
rust-0fe894e49be235ff0ac22231d7fa3579a4192f0a.zip
Deprecated `String::from_raw_parts`
Replaced by `string::raw::from_parts`

[breaking-change]
-rw-r--r--src/libcollections/str.rs3
-rw-r--r--src/libcollections/string.rs27
2 files changed, 21 insertions, 9 deletions
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 731c761351c..db859bbf5bf 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -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;
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index bb8424bd363..aeb323a9caf 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -49,14 +49,6 @@ impl 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 @@ impl 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.