about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorDenis Vasilik <contact@denisvasilik.com>2018-11-11 15:08:28 +0100
committerDenis Vasilik <contact@denisvasilik.com>2018-11-11 15:44:15 +0100
commitf0bfbd3e7201c59b5e155298fc4bdd0acece8992 (patch)
tree69291bd8b8aeda4060f143dfb27eca633a6347e4 /src/liballoc/string.rs
parent93b5112c16ec79d545826b8af1c7c27535330e77 (diff)
downloadrust-f0bfbd3e7201c59b5e155298fc4bdd0acece8992.tar.gz
rust-f0bfbd3e7201c59b5e155298fc4bdd0acece8992.zip
Added comments for trait implementations.
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 50d2c04657a..27a14bd6b8c 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -2207,7 +2207,7 @@ impl<'a> From<&'a str> for String {
 #[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.
+    /// It is notable that the `str` slice is owned.
     ///
     /// # Examples
     ///
@@ -2227,6 +2227,19 @@ impl From<Box<str>> for String {
 
 #[stable(feature = "box_from_str", since = "1.20.0")]
 impl From<String> for Box<str> {
+    /// Converts the given `String` to a boxed `str` slice that is owned.
+    ///
+    /// # Examples
+    ///
+    /// Basic usage:
+    ///
+    /// ```
+    /// let s1 = String::from("hello world");
+    /// let s2 : Box<str> = Box::from(s1);
+    /// let s3 : String = String::from(s2);
+    ///
+    /// assert_eq!("hello world", s3)
+    /// ```
     fn from(s: String) -> Box<str> {
         s.into_boxed_str()
     }
@@ -2286,6 +2299,20 @@ impl<'a> FromIterator<String> for Cow<'a, str> {
 
 #[stable(feature = "from_string_for_vec_u8", since = "1.14.0")]
 impl From<String> for Vec<u8> {
+    /// Converts the given `String` to a vector `Vec` that holds values of type `u8`.
+    ///
+    /// # Examples
+    ///
+    /// Basic usage:
+    ///
+    /// ```
+    /// let s1 = String::from("hello world");
+    /// let v1 = Vec::from(s1);
+    /// 
+    /// for b in v1 {
+    ///     println!("{}", b);
+    /// }
+    /// ```
     fn from(string: String) -> Vec<u8> {
         string.into_bytes()
     }