mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Add tests to cover all cases
This commit is contained in:
parent
85d428101d
commit
589d7e1ab4
1 changed files with 24 additions and 8 deletions
|
@ -1,12 +1,28 @@
|
|||
#![allow(unused)]
|
||||
#![warn(clippy::clear_with_drain)]
|
||||
|
||||
fn main() {
|
||||
let mut vec: Vec<i32> = Vec::new();
|
||||
//Lint
|
||||
vec.drain(..);
|
||||
vec.drain(0..vec.len());
|
||||
|
||||
// Dont Lint
|
||||
let iter = vec.drain(..);
|
||||
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
|
||||
}
|
||||
|
||||
fn range_full() {
|
||||
let (mut u, mut v) = (vec![1, 2, 3], vec![1, 2, 3]);
|
||||
let iter = u.drain(..); // Yay
|
||||
v.drain(..); // Nay
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Reference in a new issue