diff options
| author | bors <bors@rust-lang.org> | 2020-01-06 09:31:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-06 09:31:27 +0000 |
| commit | a80e63f3fa77792e848e3b248acf4c0acda2e310 (patch) | |
| tree | 6e9574bac0128d5184af68d208b2ee8d9e98e416 /src/liballoc/vec.rs | |
| parent | 33640f0e03af2fb31ce380d5389d5545f24ce29a (diff) | |
| parent | 34716a31db9371501fe98100a7aa1566f37c1d23 (diff) | |
| download | rust-a80e63f3fa77792e848e3b248acf4c0acda2e310.tar.gz rust-a80e63f3fa77792e848e3b248acf4c0acda2e310.zip | |
Auto merge of #67917 - Dylan-DPC:rollup-id05y91, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #67800 (Fix ICE involving calling `Instance.ty` during const evaluation) - #67873 (change remove to have a PartialEq bound) - #67897 (Use `as_deref()` to replace `as_ref().map(...)`) - #67906 (Silence `TooGeneric` error) - #67912 (macros: typo fix) - #67915 (Use Self instead of $type) Failed merges: r? @ghost
Diffstat (limited to 'src/liballoc/vec.rs')
| -rw-r--r-- | src/liballoc/vec.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 93a51ccb207..a27a13847d6 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1688,7 +1688,9 @@ impl<T: PartialEq> Vec<T> { pub fn dedup(&mut self) { self.dedup_by(|a, b| a == b) } +} +impl<T> Vec<T> { /// Removes the first instance of `item` from the vector if the item exists. /// /// # Examples @@ -1702,7 +1704,10 @@ impl<T: PartialEq> Vec<T> { /// 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> { + pub fn remove_item<V>(&mut self, item: &V) -> Option<T> + where + T: PartialEq<V>, + { let pos = self.iter().position(|x| *x == *item)?; Some(self.remove(pos)) } |
