Apply clippy suggestions following rust 1.50.0
This commit is contained in:
parent
96535aef6e
commit
7c7042d1dd
17
src/lib.rs
17
src/lib.rs
@ -133,7 +133,7 @@ impl Context {
|
||||
/// Create a new `Context`
|
||||
fn new(file: PathBuf) -> Context {
|
||||
Context {
|
||||
file_tree: vec![file.clone()],
|
||||
file_tree: vec![file],
|
||||
frontmatter_strategy: FrontmatterStrategy::Auto,
|
||||
}
|
||||
}
|
||||
@ -205,8 +205,8 @@ impl<'a> ObsidianNoteReference<'a> {
|
||||
|
||||
impl<'a> fmt::Display for ObsidianNoteReference<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let label = self
|
||||
.label
|
||||
let label =
|
||||
self.label
|
||||
.map(|v| v.to_string())
|
||||
.unwrap_or_else(|| match (self.file, self.section) {
|
||||
(Some(file), Some(section)) => format!("{} > {}", file, section),
|
||||
@ -214,8 +214,7 @@ impl<'a> fmt::Display for ObsidianNoteReference<'a> {
|
||||
(None, Some(section)) => section.to_string(),
|
||||
|
||||
_ => panic!("Reference exists without file or section!"),
|
||||
})
|
||||
.to_string();
|
||||
});
|
||||
write!(f, "{}", label)
|
||||
}
|
||||
}
|
||||
@ -346,10 +345,10 @@ impl<'a> Exporter<'a> {
|
||||
let write_frontmatter = match frontmatter_strategy {
|
||||
FrontmatterStrategy::Always => true,
|
||||
FrontmatterStrategy::Never => false,
|
||||
FrontmatterStrategy::Auto => frontmatter != "",
|
||||
FrontmatterStrategy::Auto => !frontmatter.is_empty(),
|
||||
};
|
||||
if write_frontmatter {
|
||||
if frontmatter != "" && !frontmatter.ends_with('\n') {
|
||||
if !frontmatter.is_empty() && !frontmatter.ends_with('\n') {
|
||||
frontmatter.push('\n');
|
||||
}
|
||||
outfile
|
||||
@ -456,7 +455,7 @@ impl<'a> Exporter<'a> {
|
||||
// - If the file being embedded is a note, it's content is included at the point of embed.
|
||||
// - If the file is an image, an image tag is generated.
|
||||
// - For other types of file, a regular link is created instead.
|
||||
fn embed_file<'b>(&self, link_text: &'a str, context: &'a Context) -> Result<MarkdownTree<'a>> {
|
||||
fn embed_file(&self, link_text: &'a str, context: &'a Context) -> Result<MarkdownTree<'a>> {
|
||||
let note_ref = ObsidianNoteReference::from_str(link_text);
|
||||
|
||||
let path = match note_ref.file {
|
||||
@ -579,7 +578,7 @@ impl<'a> Exporter<'a> {
|
||||
|
||||
let link_tag = pulldown_cmark::Tag::Link(
|
||||
pulldown_cmark::LinkType::Inline,
|
||||
CowStr::from(link.to_string()),
|
||||
CowStr::from(link),
|
||||
CowStr::from(""),
|
||||
);
|
||||
|
||||
|
14
src/main.rs
14
src/main.rs
@ -49,15 +49,17 @@ fn frontmatter_strategy_from_str(input: &str) -> Result<FrontmatterStrategy> {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
fn main() {
|
||||
let args = Opts::parse_args_default_or_exit();
|
||||
let source = args.source.unwrap();
|
||||
let destination = args.destination.unwrap();
|
||||
|
||||
let mut walk_options = WalkOptions::default();
|
||||
walk_options.ignore_filename = &args.ignore_file;
|
||||
walk_options.ignore_hidden = !args.hidden;
|
||||
walk_options.honor_gitignore = !args.no_git;
|
||||
let walk_options = WalkOptions {
|
||||
ignore_filename: &args.ignore_file,
|
||||
ignore_hidden: !args.hidden,
|
||||
honor_gitignore: !args.no_git,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut exporter = Exporter::new(source, destination);
|
||||
exporter.frontmatter_strategy(args.frontmatter_strategy);
|
||||
@ -93,6 +95,4 @@ fn main() -> Result<()> {
|
||||
};
|
||||
std::process::exit(1);
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user