diff options
| author | Denis Vasilik <contact@denisvasilik.com> | 2018-11-10 10:23:11 +0100 |
|---|---|---|
| committer | Denis Vasilik <contact@denisvasilik.com> | 2018-11-11 15:43:43 +0100 |
| commit | 93b5112c16ec79d545826b8af1c7c27535330e77 (patch) | |
| tree | 5bee2afecf81dcfb7a5a8584d0e399a274a03ff7 /src/liballoc/string.rs | |
| parent | 0366ccafa6f1740acc9c26797e08d7691d835393 (diff) | |
| download | rust-93b5112c16ec79d545826b8af1c7c27535330e77.tar.gz rust-93b5112c16ec79d545826b8af1c7c27535330e77.zip | |
Added comment for From trait implementation: boxed string slice to String
Diffstat (limited to 'src/liballoc/string.rs')
| -rw-r--r-- | src/liballoc/string.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 5c776292f53..50d2c04657a 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2206,6 +2206,20 @@ impl<'a> From<&'a str> for String { #[cfg(not(test))] #[stable(feature = "string_from_box", since = "1.18.0")] impl From<Box<str>> for String { + /// Converts the given boxed `str` slice to a `String`. + /// It is notable that the `str` slice must be owned. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// let s1 : String = String::from("hello world"); + /// let s2 : Box<str> = s1.into_boxed_str(); + /// let s3 : String = String::from(s2); + /// + /// assert_eq!("hello world", s3) + /// ``` fn from(s: Box<str>) -> String { s.into_string() } |
