-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vec::retain_mut #34265
Add Vec::retain_mut #34265
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,16 @@ fn test_retain() { | |
assert_eq!(vec, [2, 4]); | ||
} | ||
|
||
#[test] | ||
fn test_retain_mut() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe this test is necessary since as far as I known the examples in doc comments are already executed as if they were tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was following existing convention; I'm not sure of the exact benefits of having the test in both places though. |
||
let mut vec = vec![1, 2, 3, 4]; | ||
vec.retain_mut(|x| { | ||
*x -= 1; | ||
*x % 2 == 0 | ||
}); | ||
assert_eq!(vec, [0, 2]); | ||
} | ||
|
||
#[test] | ||
fn zero_sized_values() { | ||
let mut v = Vec::new(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be
f(&mut e)
.