mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
34 lines
793 B
Rust
34 lines
793 B
Rust
#![warn(clippy::cloned_instead_of_copied)]
|
|
#![allow(unused)]
|
|
#![allow(clippy::useless_vec)]
|
|
|
|
fn main() {
|
|
// yay
|
|
let _ = [1].iter().copied();
|
|
let _ = vec!["hi"].iter().copied();
|
|
let _ = Some(&1).copied();
|
|
let _ = Box::new([1].iter()).copied();
|
|
let _ = Box::new(Some(&1)).copied();
|
|
|
|
// nay
|
|
let _ = [String::new()].iter().cloned();
|
|
let _ = Some(&String::new()).cloned();
|
|
}
|
|
|
|
#[clippy::msrv = "1.34"]
|
|
fn msrv_1_34() {
|
|
let _ = [1].iter().cloned();
|
|
let _ = Some(&1).cloned();
|
|
}
|
|
|
|
#[clippy::msrv = "1.35"]
|
|
fn msrv_1_35() {
|
|
let _ = [1].iter().cloned();
|
|
let _ = Some(&1).copied(); // Option::copied needs 1.35
|
|
}
|
|
|
|
#[clippy::msrv = "1.36"]
|
|
fn msrv_1_36() {
|
|
let _ = [1].iter().copied(); // Iterator::copied needs 1.36
|
|
let _ = Some(&1).copied();
|
|
}
|