refactor: make clippy happy

This commit is contained in:
Christopher Willis-Ford 2023-03-24 14:17:53 -07:00
parent bbd9cce395
commit 693d357813
3 changed files with 19 additions and 21 deletions

View file

@ -8,15 +8,13 @@ fn copy_files<P: AsRef<Path>, Q: AsRef<Path>, R>(from_dir: P, to_dir: Q, predica
where R: Fn(&DirEntry) -> bool
{
let dir_entries = fs::read_dir(from_dir.as_ref())?;
for dir_entry in dir_entries {
if let Ok(dir_entry) = dir_entry {
let src_path = dir_entry.path();
if let Some(file_name) = src_path.file_name() {
if predicate(&dir_entry) {
let dest_path = Path::new(to_dir.as_ref()).join(file_name);
eprintln!("copy_files copying {0} to {1}", src_path.display(), dest_path.display());
fs::copy(src_path, dest_path)?;
}
for dir_entry in dir_entries.flatten() {
let src_path = dir_entry.path();
if let Some(file_name) = src_path.file_name() {
if predicate(&dir_entry) {
let dest_path = Path::new(to_dir.as_ref()).join(file_name);
eprintln!("copy_files copying {0} to {1}", src_path.display(), dest_path.display());
fs::copy(src_path, dest_path)?;
}
}
}

View file

@ -8,35 +8,35 @@ pub type ProjectLoadResult = Result<Project, ProjectLoadError>;
#[derive(Debug)]
pub enum ProjectLoadError {
IoError(std::io::Error),
ParseError(serde_json::Error),
ZipError(ZipError),
Io(std::io::Error),
Parse(serde_json::Error),
Zip(ZipError),
}
impl From<std::io::Error> for ProjectLoadError {
fn from(err: std::io::Error) -> Self {
Self::IoError(err)
Self::Io(err)
}
}
impl From<serde_json::Error> for ProjectLoadError {
fn from(err: serde_json::Error) -> Self {
Self::ParseError(err)
Self::Parse(err)
}
}
impl From<ZipError> for ProjectLoadError {
fn from(err: ZipError) -> Self {
Self::ZipError(err)
Self::Zip(err)
}
}
impl std::fmt::Display for ProjectLoadError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::IoError(err) => write!(f, "{}", err),
Self::ParseError(err) => write!(f, "{}", err),
Self::ZipError(err) => write!(f, "{}", err),
Self::Io(err) => write!(f, "{}", err),
Self::Parse(err) => write!(f, "{}", err),
Self::Zip(err) => write!(f, "{}", err),
}
}
}

View file

@ -221,9 +221,9 @@ pub struct TopLevelScript {
#[serde(untagged)]
pub enum Block {
DefineProcedure(DefineProcedure),
EBlock(EBlock),
CBlock(CBlock),
BasicBlock(BasicBlock),
E(EBlock),
C(CBlock),
Basic(BasicBlock),
}
#[derive(Debug)]