Fix new clippy lints

This commit is contained in:
Nick Groenen 2022-11-05 14:18:27 +01:00
parent 586530cac8
commit 868f1132bc
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098
3 changed files with 25 additions and 27 deletions

View File

@ -204,7 +204,7 @@ pub enum ExportError {
},
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Emitted by [Postprocessor]s to signal the next action to take.
pub enum PostprocessorResult {
/// Continue with the next post-processor (if any).
@ -743,9 +743,7 @@ fn create_file(dest: &Path) -> Result<File> {
.or_else(|err| {
if err.kind() == ErrorKind::NotFound {
let parent = dest.parent().expect("file should have a parent directory");
if let Err(err) = std::fs::create_dir_all(&parent) {
return Err(err);
}
std::fs::create_dir_all(&parent)?
}
File::create(&dest)
})
@ -758,9 +756,7 @@ fn copy_file(src: &Path, dest: &Path) -> Result<()> {
.or_else(|err| {
if err.kind() == ErrorKind::NotFound {
let parent = dest.parent().expect("file should have a parent directory");
if let Err(err) = std::fs::create_dir_all(&parent) {
return Err(err);
}
std::fs::create_dir_all(&parent)?
}
std::fs::copy(&src, &dest)
})

View File

@ -6,7 +6,7 @@ lazy_static! {
Regex::new(r"^(?P<file>[^#|]+)??(#(?P<section>.+?))??(\|(?P<label>.+?))??$").unwrap();
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
/// ObsidianNoteReference represents the structure of a `[[note]]` or `![[embed]]` reference.
pub struct ObsidianNoteReference<'a> {
/// The file (note name or partial path) being referenced.
@ -18,7 +18,7 @@ pub struct ObsidianNoteReference<'a> {
pub label: Option<&'a str>,
}
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
/// RefParserState enumerates all the possible parsing states [RefParser] may enter.
pub enum RefParserState {
NoState,

View File

@ -31,13 +31,14 @@ fn test_main_variants_with_default_options() {
continue;
};
let filename = entry.file_name().to_string_lossy().into_owned();
let expected = read_to_string(entry.path()).expect(&format!(
"failed to read {} from testdata/expected/main-samples/",
entry.path().display()
));
let actual = read_to_string(tmp_dir.path().clone().join(PathBuf::from(&filename))).expect(
&format!("failed to read {} from temporary exportdir", filename),
);
let expected = read_to_string(entry.path()).unwrap_or_else(|_| {
panic!(
"failed to read {} from testdata/expected/main-samples/",
entry.path().display()
)
});
let actual = read_to_string(tmp_dir.path().clone().join(PathBuf::from(&filename)))
.unwrap_or_else(|_| panic!("failed to read {} from temporary exportdir", filename));
assert_eq!(
expected, actual,
@ -170,7 +171,7 @@ fn test_start_at_subdir() {
let expected = if cfg!(windows) {
read_to_string("tests/testdata/expected/start-at/subdir/Note B.md")
.unwrap()
.replace("/", "\\")
.replace('/', "\\")
} else {
read_to_string("tests/testdata/expected/start-at/subdir/Note B.md").unwrap()
};
@ -196,7 +197,7 @@ fn test_start_at_file_within_subdir_destination_is_dir() {
let expected = if cfg!(windows) {
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md")
.unwrap()
.replace("/", "\\")
.replace('/', "\\")
} else {
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md").unwrap()
};
@ -223,7 +224,7 @@ fn test_start_at_file_within_subdir_destination_is_file() {
let expected = if cfg!(windows) {
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md")
.unwrap()
.replace("/", "\\")
.replace('/', "\\")
} else {
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md").unwrap()
};
@ -385,13 +386,14 @@ fn test_non_ascii_filenames() {
continue;
};
let filename = entry.file_name().to_string_lossy().into_owned();
let expected = read_to_string(entry.path()).expect(&format!(
"failed to read {} from testdata/expected/non-ascii/",
entry.path().display()
));
let actual = read_to_string(tmp_dir.path().clone().join(PathBuf::from(&filename))).expect(
&format!("failed to read {} from temporary exportdir", filename),
);
let expected = read_to_string(entry.path()).unwrap_or_else(|_| {
panic!(
"failed to read {} from testdata/expected/non-ascii/",
entry.path().display()
)
});
let actual = read_to_string(tmp_dir.path().clone().join(PathBuf::from(&filename)))
.unwrap_or_else(|_| panic!("failed to read {} from temporary exportdir", filename));
assert_eq!(
expected, actual,
@ -414,7 +416,7 @@ fn test_same_filename_different_directories() {
let expected = if cfg!(windows) {
read_to_string("tests/testdata/expected/same-filename-different-directories/Note.md")
.unwrap()
.replace("/", "\\")
.replace('/', "\\")
} else {
read_to_string("tests/testdata/expected/same-filename-different-directories/Note.md")
.unwrap()