Fix new clippy lints
This commit is contained in:
parent
586530cac8
commit
868f1132bc
10
src/lib.rs
10
src/lib.rs
@ -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.
|
/// Emitted by [Postprocessor]s to signal the next action to take.
|
||||||
pub enum PostprocessorResult {
|
pub enum PostprocessorResult {
|
||||||
/// Continue with the next post-processor (if any).
|
/// Continue with the next post-processor (if any).
|
||||||
@ -743,9 +743,7 @@ fn create_file(dest: &Path) -> Result<File> {
|
|||||||
.or_else(|err| {
|
.or_else(|err| {
|
||||||
if err.kind() == ErrorKind::NotFound {
|
if err.kind() == ErrorKind::NotFound {
|
||||||
let parent = dest.parent().expect("file should have a parent directory");
|
let parent = dest.parent().expect("file should have a parent directory");
|
||||||
if let Err(err) = std::fs::create_dir_all(&parent) {
|
std::fs::create_dir_all(&parent)?
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
File::create(&dest)
|
File::create(&dest)
|
||||||
})
|
})
|
||||||
@ -758,9 +756,7 @@ fn copy_file(src: &Path, dest: &Path) -> Result<()> {
|
|||||||
.or_else(|err| {
|
.or_else(|err| {
|
||||||
if err.kind() == ErrorKind::NotFound {
|
if err.kind() == ErrorKind::NotFound {
|
||||||
let parent = dest.parent().expect("file should have a parent directory");
|
let parent = dest.parent().expect("file should have a parent directory");
|
||||||
if let Err(err) = std::fs::create_dir_all(&parent) {
|
std::fs::create_dir_all(&parent)?
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
std::fs::copy(&src, &dest)
|
std::fs::copy(&src, &dest)
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,7 @@ lazy_static! {
|
|||||||
Regex::new(r"^(?P<file>[^#|]+)??(#(?P<section>.+?))??(\|(?P<label>.+?))??$").unwrap();
|
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.
|
/// ObsidianNoteReference represents the structure of a `[[note]]` or `![[embed]]` reference.
|
||||||
pub struct ObsidianNoteReference<'a> {
|
pub struct ObsidianNoteReference<'a> {
|
||||||
/// The file (note name or partial path) being referenced.
|
/// The file (note name or partial path) being referenced.
|
||||||
@ -18,7 +18,7 @@ pub struct ObsidianNoteReference<'a> {
|
|||||||
pub label: Option<&'a str>,
|
pub label: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq, Eq)]
|
||||||
/// RefParserState enumerates all the possible parsing states [RefParser] may enter.
|
/// RefParserState enumerates all the possible parsing states [RefParser] may enter.
|
||||||
pub enum RefParserState {
|
pub enum RefParserState {
|
||||||
NoState,
|
NoState,
|
||||||
|
@ -31,13 +31,14 @@ fn test_main_variants_with_default_options() {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let filename = entry.file_name().to_string_lossy().into_owned();
|
let filename = entry.file_name().to_string_lossy().into_owned();
|
||||||
let expected = read_to_string(entry.path()).expect(&format!(
|
let expected = read_to_string(entry.path()).unwrap_or_else(|_| {
|
||||||
"failed to read {} from testdata/expected/main-samples/",
|
panic!(
|
||||||
entry.path().display()
|
"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 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!(
|
assert_eq!(
|
||||||
expected, actual,
|
expected, actual,
|
||||||
@ -170,7 +171,7 @@ fn test_start_at_subdir() {
|
|||||||
let expected = if cfg!(windows) {
|
let expected = if cfg!(windows) {
|
||||||
read_to_string("tests/testdata/expected/start-at/subdir/Note B.md")
|
read_to_string("tests/testdata/expected/start-at/subdir/Note B.md")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace("/", "\\")
|
.replace('/', "\\")
|
||||||
} else {
|
} else {
|
||||||
read_to_string("tests/testdata/expected/start-at/subdir/Note B.md").unwrap()
|
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) {
|
let expected = if cfg!(windows) {
|
||||||
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md")
|
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace("/", "\\")
|
.replace('/', "\\")
|
||||||
} else {
|
} else {
|
||||||
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md").unwrap()
|
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) {
|
let expected = if cfg!(windows) {
|
||||||
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md")
|
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace("/", "\\")
|
.replace('/', "\\")
|
||||||
} else {
|
} else {
|
||||||
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md").unwrap()
|
read_to_string("tests/testdata/expected/start-at/single-file/Note B.md").unwrap()
|
||||||
};
|
};
|
||||||
@ -385,13 +386,14 @@ fn test_non_ascii_filenames() {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let filename = entry.file_name().to_string_lossy().into_owned();
|
let filename = entry.file_name().to_string_lossy().into_owned();
|
||||||
let expected = read_to_string(entry.path()).expect(&format!(
|
let expected = read_to_string(entry.path()).unwrap_or_else(|_| {
|
||||||
"failed to read {} from testdata/expected/non-ascii/",
|
panic!(
|
||||||
entry.path().display()
|
"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 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!(
|
assert_eq!(
|
||||||
expected, actual,
|
expected, actual,
|
||||||
@ -414,7 +416,7 @@ fn test_same_filename_different_directories() {
|
|||||||
let expected = if cfg!(windows) {
|
let expected = if cfg!(windows) {
|
||||||
read_to_string("tests/testdata/expected/same-filename-different-directories/Note.md")
|
read_to_string("tests/testdata/expected/same-filename-different-directories/Note.md")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace("/", "\\")
|
.replace('/', "\\")
|
||||||
} else {
|
} else {
|
||||||
read_to_string("tests/testdata/expected/same-filename-different-directories/Note.md")
|
read_to_string("tests/testdata/expected/same-filename-different-directories/Note.md")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user