Remove needless borrows
This commit is contained in:
parent
6af4c9140c
commit
be5cf58c1a
18
src/lib.rs
18
src/lib.rs
@ -438,7 +438,7 @@ impl<'a> Exporter<'a> {
|
|||||||
file_tree: context.file_tree(),
|
file_tree: context.file_tree(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let content = fs::read_to_string(&path).context(ReadSnafu { path })?;
|
let content = fs::read_to_string(path).context(ReadSnafu { path })?;
|
||||||
let (frontmatter, content) =
|
let (frontmatter, content) =
|
||||||
matter::matter(&content).unwrap_or(("".to_string(), content.to_string()));
|
matter::matter(&content).unwrap_or(("".to_string(), content.to_string()));
|
||||||
let frontmatter =
|
let frontmatter =
|
||||||
@ -677,7 +677,7 @@ impl<'a> Exporter<'a> {
|
|||||||
// in case of embedded notes.
|
// in case of embedded notes.
|
||||||
let rel_link = diff_paths(
|
let rel_link = diff_paths(
|
||||||
target_file,
|
target_file,
|
||||||
&context
|
context
|
||||||
.root_file()
|
.root_file()
|
||||||
.parent()
|
.parent()
|
||||||
.expect("obsidian content files should always have a parent"),
|
.expect("obsidian content files should always have a parent"),
|
||||||
@ -718,7 +718,7 @@ fn lookup_filename_in_vault<'a>(
|
|||||||
// lookup.
|
// lookup.
|
||||||
vault_contents.iter().find(|path| {
|
vault_contents.iter().find(|path| {
|
||||||
let path_lowered = PathBuf::from(path.to_string_lossy().to_lowercase());
|
let path_lowered = PathBuf::from(path.to_string_lossy().to_lowercase());
|
||||||
path.ends_with(&filename)
|
path.ends_with(filename)
|
||||||
|| path_lowered.ends_with(&filename.to_lowercase())
|
|| path_lowered.ends_with(&filename.to_lowercase())
|
||||||
|| path.ends_with(format!("{}.md", &filename))
|
|| path.ends_with(format!("{}.md", &filename))
|
||||||
|| path_lowered.ends_with(format!("{}.md", &filename.to_lowercase()))
|
|| path_lowered.ends_with(format!("{}.md", &filename.to_lowercase()))
|
||||||
@ -738,26 +738,26 @@ fn render_mdevents_to_mdtext(markdown: MarkdownEvents) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_file(dest: &Path) -> Result<File> {
|
fn create_file(dest: &Path) -> Result<File> {
|
||||||
let file = File::create(&dest)
|
let file = File::create(dest)
|
||||||
.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");
|
||||||
std::fs::create_dir_all(&parent)?
|
std::fs::create_dir_all(parent)?
|
||||||
}
|
}
|
||||||
File::create(&dest)
|
File::create(dest)
|
||||||
})
|
})
|
||||||
.context(WriteSnafu { path: dest })?;
|
.context(WriteSnafu { path: dest })?;
|
||||||
Ok(file)
|
Ok(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_file(src: &Path, dest: &Path) -> Result<()> {
|
fn copy_file(src: &Path, dest: &Path) -> Result<()> {
|
||||||
std::fs::copy(&src, &dest)
|
std::fs::copy(src, dest)
|
||||||
.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");
|
||||||
std::fs::create_dir_all(&parent)?
|
std::fs::create_dir_all(parent)?
|
||||||
}
|
}
|
||||||
std::fs::copy(&src, &dest)
|
std::fs::copy(src, dest)
|
||||||
})
|
})
|
||||||
.context(WriteSnafu { path: dest })?;
|
.context(WriteSnafu { path: dest })?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user