Skip to content

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Jun 2, 2024
1 parent 2459e82 commit 79ddad8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lang/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ msgstr ""
msgid "Project file is younger than pdf, continue anyway?"
msgstr ""

#: /Users/hendrik/code/rust/asciii/src/lib.rs:70
#: /Users/hendrik/code/rust/asciii/src/lib.rs:68
msgid "Documentation at: {}"
msgstr ""

Expand Down
36 changes: 18 additions & 18 deletions src/document_export/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@ impl HelperDef for IncHelper {
}
}

#[derive(Clone, Copy)]
struct CountHelper;

impl HelperDef for CountHelper {
#[allow(clippy::extra_unused_lifetimes)]
fn call<'reg: 'rc, 'rc>(
&self,
h: &Helper<'_, '_>,
_: &Handlebars,
_: &Context,
_: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> HelperResult {
let count = h.param(0).unwrap().value().as_array().map_or(0, Vec::len);
out.write(&format!("{}", count))?;
Ok(())
}
}
// #[derive(Clone, Copy)]
// struct CountHelper;

// impl HelperDef for CountHelper {
// #[allow(clippy::extra_unused_lifetimes)]
// fn call<'reg: 'rc, 'rc>(
// &self,
// h: &Helper<'_, '_>,
// _: &Handlebars,
// _: &Context,
// _: &mut RenderContext<'_, '_>,
// out: &mut dyn Output,
// ) -> HelperResult {
// let count = h.param(0).unwrap().value().as_array().map_or(0, Vec::len);
// out.write(&format!("{}", count))?;
// Ok(())
// }
// }

/// Takes a `T: Serialize` and a template path and does it's thing.
///
Expand Down
1 change: 1 addition & 0 deletions src/project/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl ToString for ExportFloat {
}
}
}

impl serde::Serialize for ExportFloat {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
4 changes: 2 additions & 2 deletions src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Project {
}

/// Opens a project from file path;
pub fn open<S: AsRef<OsStr> + std::fmt::Debug + ?Sized>(pathish: &S) -> Result<Project, Error> {
pub fn open<S: AsRef<OsStr> + fmt::Debug + ?Sized>(pathish: &S) -> Result<Project, Error> {
log::trace!("Project::open({:?});", pathish);
let file_path = Path::new(&pathish);
let file_content = fs::read_to_string(file_path)?;
Expand Down Expand Up @@ -710,7 +710,7 @@ impl Storable for Project {
self.file_path.clone()
} // TODO: reconsider returning PathBuf at all
fn set_file(&mut self, new_file: &Path) {
self.file_path = new_file.to_owned();
new_file.clone_into(&mut self.file_path);
}

fn set_git_status(&mut self, status: GitStatus) {
Expand Down
2 changes: 1 addition & 1 deletion src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Default for StorageSelection {

fn is_dot_file(path: &Path) -> bool {
path.file_name()
.and_then(std::ffi::OsStr::to_str)
.and_then(OsStr::to_str)
.and_then(|s| s.chars().next())
.map(|c| c == '.')
.unwrap_or(false)
Expand Down
2 changes: 1 addition & 1 deletion src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn get_valid_path<T: AsRef<OsStr>>(p: T) -> Option<PathBuf> {
let path = replace_home_tilde(Path::new(&p));
let path = if path.is_relative() {
if cfg!(target_arch = "wasm32") {
Ok(PathBuf::from(std::env::var("PWD").expect("can't access $PWD")))
Ok(PathBuf::from(env::var("PWD").expect("can't access $PWD")))
} else {
current_dir()
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn open(path: &Path) -> Result<Yaml, anyhow::Error> {
/// Ruby like API to yaml-rust.
pub fn parse(file_content: &str) -> Result<Yaml, anyhow::Error> {
Ok(YamlLoader::load_from_str(file_content)?
.get(0)
.first()
.map(ToOwned::to_owned)
.unwrap_or_else(|| Yaml::from_str("[]")))
}
Expand Down

0 comments on commit 79ddad8

Please sign in to comment.