Don't borrow references that are immediately dereferenced

This was caught by a recently introduced clippy rule
This commit is contained in:
Nick Groenen 2021-08-27 11:27:46 +02:00
parent 82798daa89
commit c64d75967e
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098
2 changed files with 6 additions and 6 deletions

View File

@ -357,7 +357,7 @@ impl<'a> Exporter<'a> {
fn parse_and_export_obsidian_note(&self, src: &Path, dest: &Path) -> Result<()> {
let mut context = Context::new(src.to_path_buf(), dest.to_path_buf());
let (frontmatter, mut markdown_events) = self.parse_obsidian_note(&src, &context)?;
let (frontmatter, mut markdown_events) = self.parse_obsidian_note(src, &context)?;
context.frontmatter = frontmatter;
for func in &self.postprocessors {
let res = func(context, markdown_events);
@ -526,12 +526,12 @@ impl<'a> Exporter<'a> {
let note_ref = ObsidianNoteReference::from_str(link_text);
let path = match note_ref.file {
Some(file) => lookup_filename_in_vault(file, &self.vault_contents.as_ref().unwrap()),
Some(file) => lookup_filename_in_vault(file, self.vault_contents.as_ref().unwrap()),
// If we have None file it is either to a section or id within the same file and thus
// the current embed logic will fail, recurssing until it reaches it's limit.
// For now we just bail early.
None => return Ok(self.make_link_to_file(note_ref, &context)),
None => return Ok(self.make_link_to_file(note_ref, context)),
};
if path.is_none() {
@ -560,7 +560,7 @@ impl<'a> Exporter<'a> {
let events = match path.extension().unwrap_or(&no_ext).to_str() {
Some("md") => {
let (_frontmatter, mut events) = self.parse_obsidian_note(&path, &child_context)?;
let (_frontmatter, mut events) = self.parse_obsidian_note(path, &child_context)?;
if let Some(section) = note_ref.section {
events = reduce_to_section(events, section);
}
@ -604,7 +604,7 @@ impl<'a> Exporter<'a> {
) -> MarkdownEvents<'c> {
let target_file = reference
.file
.map(|file| lookup_filename_in_vault(file, &self.vault_contents.as_ref().unwrap()))
.map(|file| lookup_filename_in_vault(file, self.vault_contents.as_ref().unwrap()))
.unwrap_or_else(|| Some(context.current_file()));
if target_file.is_none() {

View File

@ -71,7 +71,7 @@ impl RefParser {
impl<'a> ObsidianNoteReference<'a> {
pub fn from_str(text: &str) -> ObsidianNoteReference {
let captures = OBSIDIAN_NOTE_LINK_RE
.captures(&text)
.captures(text)
.expect("note link regex didn't match - bad input?");
let file = captures.name("file").map(|v| v.as_str());
let label = captures.name("label").map(|v| v.as_str());