about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-03-09 08:26:17 +0000
committerbors <bors@rust-lang.org>2017-03-09 08:26:17 +0000
commit3087a1f39eaeac9d76c8b159dcc64de515bb2b83 (patch)
treebace37e5277d56098ee4d1bb0727d930d68b650c /src/libcollections
parent5c9208faf1f180cd15cf93f74f1e57b24856d11e (diff)
parentf2886e8bda7d628ae0cc16e4fe579cbc2c6dc1b0 (diff)
downloadrust-3087a1f39eaeac9d76c8b159dcc64de515bb2b83.tar.gz
rust-3087a1f39eaeac9d76c8b159dcc64de515bb2b83.zip
Auto merge of #40368 - arielb1:rollup, r=arielb1
Rollup of 20 pull requests

- Successful merges: #40154, #40222, #40226, #40237, #40254, #40258, #40265, #40268, #40279, #40283, #40292, #40293, #40296, #40316, #40321, #40325, #40326, #40327, #40333, #40335
- Failed merges:
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/str.rs8
-rw-r--r--src/libcollections/string.rs8
-rw-r--r--src/libcollections/vec.rs21
3 files changed, 37 insertions, 0 deletions
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 87315fff0a0..e27c4577344 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -1646,6 +1646,10 @@ impl str {
     /// 'Lowercase' is defined according to the terms of the Unicode Derived Core Property
     /// `Lowercase`.
     ///
+    /// Since some characters can expand into multiple characters when changing
+    /// the case, this function returns a [`String`] instead of modifying the
+    /// parameter in-place.
+    ///
     /// [`String`]: string/struct.String.html
     ///
     /// # Examples
@@ -1718,6 +1722,10 @@ impl str {
     /// 'Uppercase' is defined according to the terms of the Unicode Derived Core Property
     /// `Uppercase`.
     ///
+    /// Since some characters can expand into multiple characters when changing
+    /// the case, this function returns a [`String`] instead of modifying the
+    /// parameter in-place.
+    ///
     /// [`String`]: string/struct.String.html
     ///
     /// # Examples
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 4979107ccad..43323676ab4 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -433,6 +433,10 @@ impl String {
     ///
     /// [`str::from_utf8()`]: ../../std/str/fn.from_utf8.html
     ///
+    /// The inverse of this method is [`as_bytes`].
+    ///
+    /// [`as_bytes`]: #method.as_bytes
+    ///
     /// # Errors
     ///
     /// Returns `Err` if the slice is not UTF-8 with a description as to why the
@@ -979,6 +983,10 @@ impl String {
 
     /// Returns a byte slice of this `String`'s contents.
     ///
+    /// The inverse of this method is [`from_utf8`].
+    ///
+    /// [`from_utf8`]: #method.from_utf8
+    ///
     /// # Examples
     ///
     /// Basic usage:
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 3134e3c2ce1..d38c9f6e1cf 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1335,6 +1335,27 @@ impl<T: PartialEq> Vec<T> {
     pub fn dedup(&mut self) {
         self.dedup_by(|a, b| a == b)
     }
+
+    /// Removes the first instance of `item` from the vector if the item exists.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    ///# #![feature(vec_remove_item)]
+    /// let mut vec = vec![1, 2, 3, 1];
+    ///
+    /// vec.remove_item(&1);
+    ///
+    /// assert_eq!(vec, vec![2, 3, 1]);
+    /// ```
+    #[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
+    pub fn remove_item(&mut self, item: &T) -> Option<T> {
+        let pos = match self.iter().position(|x| *x == *item) {
+            Some(x) => x,
+            None => return None,
+        };
+        Some(self.remove(pos))
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////