@@ -49,14 +49,6 @@ impl String {
49
49
}
50
50
}
51
51
52
- /// Creates a new string buffer from length, capacity, and a pointer.
53
- #[ inline]
54
- pub unsafe fn from_raw_parts ( length : uint , capacity : uint , ptr : * mut u8 ) -> String {
55
- String {
56
- vec : Vec :: from_raw_parts ( length, capacity, ptr) ,
57
- }
58
- }
59
-
60
52
/// Creates a new string buffer from the given string.
61
53
#[ inline]
62
54
pub fn from_str ( string : & str ) -> String {
@@ -65,6 +57,13 @@ impl String {
65
57
}
66
58
}
67
59
60
+ /// Deprecated. Replaced by `string::raw::from_parts`
61
+ #[ inline]
62
+ #[ deprecated = "Replaced by string::raw::from_parts" ]
63
+ pub unsafe fn from_raw_parts ( length : uint , capacity : uint , ptr : * mut u8 ) -> String {
64
+ raw:: from_parts ( length, capacity, ptr)
65
+ }
66
+
68
67
#[ allow( missing_doc) ]
69
68
#[ deprecated = "obsoleted by the removal of ~str" ]
70
69
#[ inline]
@@ -577,6 +576,18 @@ pub mod raw {
577
576
use super :: String ;
578
577
use vec:: Vec ;
579
578
579
+ /// Creates a new `String` from length, capacity, and a pointer.
580
+ ///
581
+ /// This is unsafe because:
582
+ /// * We call `Vec::from_raw_parts` to get a `Vec<u8>`
583
+ /// * We assume that the `Vec` contains valid UTF-8
584
+ #[ inline]
585
+ pub unsafe fn from_parts ( length : uint , capacity : uint , ptr : * mut u8 ) -> String {
586
+ String {
587
+ vec : Vec :: from_raw_parts ( length, capacity, ptr) ,
588
+ }
589
+ }
590
+
580
591
/// Converts a vector of bytes to a new `String` without checking if
581
592
/// it contains valid UTF-8. This is unsafe because it assumes that
582
593
/// the utf-8-ness of the vector has already been validated.
0 commit comments