Skip to content

Commit

Permalink
Apply cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Aug 7, 2024
1 parent 01a7fb5 commit de03f87
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 254 deletions.
16 changes: 7 additions & 9 deletions cpclib-bndbuild/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use minijinja::{context, Environment, Error, ErrorKind};
use crate::rules::{self, Graph, Rule};
use crate::BndBuilderError;

pub const EXPECTED_FILENAMES: &'static[&'static str] = &["bndbuild.yml", "build.bnd"];
pub const EXPECTED_FILENAMES: &'static [&'static str] = &["bndbuild.yml", "build.bnd"];

self_cell::self_cell! {
/// WARNING the BndBuilder changes the current working directory.
Expand All @@ -21,10 +21,8 @@ self_cell::self_cell! {
}
}



pub struct BndBuilder {
inner: BndBuilderInner,
inner: BndBuilderInner
}

impl Deref for BndBuilder {
Expand Down Expand Up @@ -52,11 +50,12 @@ impl BndBuilder {

pub fn from_path<P: AsRef<Utf8Path>>(fname: P) -> Result<(Utf8PathBuf, Self), BndBuilderError> {
let (p, content) = Self::decode_from_fname(fname)?;
Self::from_string(content)
.map(|build| (p, build))
Self::from_string(content).map(|build| (p, build))
}

pub fn decode_from_fname<P: AsRef<Utf8Path>>(fname: P) -> Result<(Utf8PathBuf, String), BndBuilderError> {
pub fn decode_from_fname<P: AsRef<Utf8Path>>(
fname: P
) -> Result<(Utf8PathBuf, String), BndBuilderError> {
Self::decode_from_fname_with_definitions(fname, &Vec::<(String, String)>::new())
}

Expand Down Expand Up @@ -98,8 +97,7 @@ impl BndBuilder {
let working_directory = if path.is_dir() { Some(path) } else { None };

let rdr = BufReader::new(file);
Self::decode_from_reader(rdr, working_directory, definitions)
.map(|s| (fname.to_owned(), s))
Self::decode_from_reader(rdr, working_directory, definitions).map(|s| (fname.to_owned(), s))
}

pub fn save<P: AsRef<Utf8Path>>(&self, path: P) -> std::io::Result<()> {
Expand Down
4 changes: 1 addition & 3 deletions cpclib-bndbuild/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ pub static XFER_RUNNER: LazyLock<XferRunner> = LazyLock::new(|| XferRunner::defa

pub fn execute(task: &Task) -> Result<(), String> {
match task {
Task::Emulator(e,_ ) => {
EmulatorRunner{emu:e.clone()}.run(task.args())
},
Task::Emulator(e, _) => EmulatorRunner { emu: e.clone() }.run(task.args()),
Task::Basm(_) => BASM_RUNNER.run(task.args()),
Task::BndBuild(_) => BNDBUILD_RUNNER.run(task.args()),
Task::Cp(_) => CP_RUNNER.run(task.args()),
Expand Down
3 changes: 2 additions & 1 deletion cpclib-bndbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ pub fn process_matches(cmd: Command, matches: &ArgMatches) -> Result<(), BndBuil
// Get the file
let fname = if let Some(fname) = matches.get_one::<String>("file") {
fname.as_str()
} else {
}
else {
let mut selected = &EXPECTED_FILENAMES[1];
for fname in EXPECTED_FILENAMES {
if Utf8Path::new(fname).exists() {
Expand Down
Loading

0 comments on commit de03f87

Please sign in to comment.