@@ -2206,13 +2206,40 @@ impl<'a> From<&'a str> for String {
2206
2206
#[ cfg( not( test) ) ]
2207
2207
#[ stable( feature = "string_from_box" , since = "1.18.0" ) ]
2208
2208
impl From < Box < str > > for String {
2209
+ /// Converts the given boxed `str` slice to a `String`.
2210
+ /// It is notable that the `str` slice is owned.
2211
+ ///
2212
+ /// # Examples
2213
+ ///
2214
+ /// Basic usage:
2215
+ ///
2216
+ /// ```
2217
+ /// let s1: String = String::from("hello world");
2218
+ /// let s2: Box<str> = s1.into_boxed_str();
2219
+ /// let s3: String = String::from(s2);
2220
+ ///
2221
+ /// assert_eq!("hello world", s3)
2222
+ /// ```
2209
2223
fn from ( s : Box < str > ) -> String {
2210
2224
s. into_string ( )
2211
2225
}
2212
2226
}
2213
2227
2214
2228
#[ stable( feature = "box_from_str" , since = "1.20.0" ) ]
2215
2229
impl From < String > for Box < str > {
2230
+ /// Converts the given `String` to a boxed `str` slice that is owned.
2231
+ ///
2232
+ /// # Examples
2233
+ ///
2234
+ /// Basic usage:
2235
+ ///
2236
+ /// ```
2237
+ /// let s1: String = String::from("hello world");
2238
+ /// let s2: Box<str> = Box::from(s1);
2239
+ /// let s3: String = String::from(s2);
2240
+ ///
2241
+ /// assert_eq!("hello world", s3)
2242
+ /// ```
2216
2243
fn from ( s : String ) -> Box < str > {
2217
2244
s. into_boxed_str ( )
2218
2245
}
@@ -2272,6 +2299,20 @@ impl<'a> FromIterator<String> for Cow<'a, str> {
2272
2299
2273
2300
#[ stable( feature = "from_string_for_vec_u8" , since = "1.14.0" ) ]
2274
2301
impl From < String > for Vec < u8 > {
2302
+ /// Converts the given `String` to a vector `Vec` that holds values of type `u8`.
2303
+ ///
2304
+ /// # Examples
2305
+ ///
2306
+ /// Basic usage:
2307
+ ///
2308
+ /// ```
2309
+ /// let s1 = String::from("hello world");
2310
+ /// let v1 = Vec::from(s1);
2311
+ ///
2312
+ /// for b in v1 {
2313
+ /// println!("{}", b);
2314
+ /// }
2315
+ /// ```
2275
2316
fn from ( string : String ) -> Vec < u8 > {
2276
2317
string. into_bytes ( )
2277
2318
}
0 commit comments