3 #![allow(unused_assignments)]
4 #![warn(clippy::unnecessary_to_owned)]
15 let path = std::path::Path::new("x");
17 let _ = check_files(&[(FileType::Account, path)]);
18 let _ = check_files_vec(vec![(FileType::Account, path)]);
21 let _ = check_files_ref(&[(FileType::Account, path)]);
22 let _ = check_files_mut(&[(FileType::Account, path)]);
23 let _ = check_files_ref_mut(&[(FileType::Account, path)]);
24 let _ = check_files_self_and_arg(&[(FileType::Account, path)]);
25 let _ = check_files_mut_path_buf(&[(FileType::Account, std::path::PathBuf::new())]);
28 // `check_files` and its variants are based on:
29 // https://github.com/breard-r/acmed/blob/1f0dcc32aadbc5e52de6d23b9703554c0f925113/acmed/src/storage.rs#L262
30 fn check_files(files: &[(FileType, &std::path::Path)]) -> bool {
31 for (t, path) in files {
32 let other = match get_file_path(t) {
38 if !path.is_file() || !other.is_file() {
45 fn check_files_vec(files: Vec<(FileType, &std::path::Path)>) -> bool {
46 for (t, path) in files.iter() {
47 let other = match get_file_path(t) {
53 if !path.is_file() || !other.is_file() {
60 fn check_files_ref(files: &[(FileType, &std::path::Path)]) -> bool {
61 for (ref t, path) in files.iter().copied() {
62 let other = match get_file_path(t) {
68 if !path.is_file() || !other.is_file() {
75 #[allow(unused_assignments)]
76 fn check_files_mut(files: &[(FileType, &std::path::Path)]) -> bool {
77 for (mut t, path) in files.iter().copied() {
78 t = FileType::PrivateKey;
79 let other = match get_file_path(&t) {
85 if !path.is_file() || !other.is_file() {
92 fn check_files_ref_mut(files: &[(FileType, &std::path::Path)]) -> bool {
93 for (ref mut t, path) in files.iter().copied() {
94 *t = FileType::PrivateKey;
95 let other = match get_file_path(t) {
101 if !path.is_file() || !other.is_file() {
108 fn check_files_self_and_arg(files: &[(FileType, &std::path::Path)]) -> bool {
109 for (t, path) in files.iter().copied() {
110 let other = match get_file_path(&t) {
116 if !path.join(path).is_file() || !other.is_file() {
123 #[allow(unused_assignments)]
124 fn check_files_mut_path_buf(files: &[(FileType, std::path::PathBuf)]) -> bool {
125 for (mut t, path) in files.iter().cloned() {
126 t = FileType::PrivateKey;
127 let other = match get_file_path(&t) {
133 if !path.is_file() || !other.is_file() {
140 fn get_file_path(_file_type: &FileType) -> Result<std::path::PathBuf, std::io::Error> {
141 Ok(std::path::PathBuf::new())