Skip to content

Commit 37057e7

Browse files
authored
Added documentation to remove_item
1 parent 8a02141 commit 37057e7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/libcollections/vec.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,18 @@ impl<T: PartialEq> Vec<T> {
12961296
pub fn dedup(&mut self) {
12971297
self.dedup_by(|a, b| a == b)
12981298
}
1299-
1299+
1300+
/// Removes the first instance of `item` from the vector if the item exists.
1301+
///
1302+
/// # Examples
1303+
///
1304+
/// ```
1305+
/// let mut vec = vec![1, 2, 3, 1];
1306+
///
1307+
/// vec.remove_item(&1);
1308+
///
1309+
/// assert_eq!(vec, vec![2, 3, 1]);
1310+
/// ```
13001311
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "38143")]
13011312
pub fn remove_item(&mut self, item: &T) -> Option<T> {
13021313
let pos = match self.iter().position(|x| *x == *item) {

0 commit comments

Comments
 (0)