mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +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)]
|
#![allow(unused)]
|
||||||
#![warn(clippy::clear_with_drain)]
|
#![warn(clippy::clear_with_drain)]
|
||||||
|
|
||||||
fn main() {
|
fn range() {
|
||||||
let mut vec: Vec<i32> = Vec::new();
|
let (mut u, mut v) = (vec![1, 2, 3], vec![1, 2, 3]);
|
||||||
//Lint
|
let iter = u.drain(0..u.len()); // Yay
|
||||||
vec.drain(..);
|
v.drain(0..v.len()); // Nay
|
||||||
vec.drain(0..vec.len());
|
|
||||||
|
|
||||||
// Dont Lint
|
|
||||||
let iter = vec.drain(..);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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