2023-03-21 21:46:59 +00:00
|
|
|
// run-rustfix
|
2023-03-18 09:43:02 +00:00
|
|
|
#![allow(unused)]
|
|
|
|
#![warn(clippy::clear_with_drain)]
|
|
|
|
|
2023-03-18 13:45:57 +00:00
|
|
|
fn range() {
|
|
|
|
let (mut u, mut v) = (vec![1, 2, 3], vec![1, 2, 3]);
|
|
|
|
let iter = u.drain(0..u.len()); // Yay
|
|
|
|
v.drain(0..v.len()); // Nay
|
|
|
|
}
|
|
|
|
|
|
|
|
fn range_from() {
|
|
|
|
let (mut u, mut v) = (vec![1, 2, 3], vec![1, 2, 3]);
|
|
|
|
let iter = u.drain(0..); // Yay
|
|
|
|
v.drain(0..); // Nay
|
|
|
|
}
|
2023-03-18 09:43:02 +00:00
|
|
|
|
2023-03-18 13:45:57 +00:00
|
|
|
fn range_full() {
|
|
|
|
let (mut u, mut v) = (vec![1, 2, 3], vec![1, 2, 3]);
|
|
|
|
let iter = u.drain(..); // Yay
|
|
|
|
v.drain(..); // Nay
|
2023-03-18 09:43:02 +00:00
|
|
|
}
|
2023-03-18 13:45:57 +00:00
|
|
|
|
|
|
|
fn range_to() {
|
|
|
|
let (mut u, mut v) = (vec![1, 2, 3], vec![1, 2, 3]);
|
|
|
|
let iter = u.drain(..u.len()); // Yay
|
|
|
|
v.drain(..v.len()); // Nay
|
|
|
|
}
|
|
|
|
|
2023-03-21 21:09:26 +00:00
|
|
|
fn partial_drains() {
|
|
|
|
let mut v = vec![1, 2, 3];
|
|
|
|
v.drain(1..); // Yay
|
|
|
|
|
|
|
|
let mut v = vec![1, 2, 3];
|
|
|
|
v.drain(..v.len() - 1); // Yay
|
|
|
|
|
|
|
|
let mut v = vec![1, 2, 3];
|
|
|
|
v.drain(1..v.len() - 1); // Yay
|
|
|
|
}
|
|
|
|
|
2023-03-18 13:45:57 +00:00
|
|
|
fn main() {}
|