Skip to content

Commit

Permalink
fix code fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Oct 27, 2023
1 parent 0dec882 commit ccf6755
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 87 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/ctrl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-controls"
version = "0.3.1"
version = "0.3.2"
readme = "README.md"
description = "High-level controls API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand Down
2 changes: 1 addition & 1 deletion api/ctrl/src/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub struct PDButtonsDisplay<'t>(&'t PDButtons);

impl<'t> Debug for PDButtonsDisplay<'t> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut fmt = f.debug_tuple(&format!("PDButtons[{:08b}]", self.0 .0));
let mut fmt = f.debug_tuple(&format!("PDButtons[{:08b}]", self.0.0));
let iter = self.0.iter().singles();
for item in iter {
fmt.field(&item);
Expand Down
2 changes: 1 addition & 1 deletion api/gfx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-graphics"
version = "0.3.10"
version = "0.3.11"
readme = "README.md"
description = "High-level graphics API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand Down
6 changes: 1 addition & 5 deletions api/gfx/src/bitmap/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,7 @@ impl<Api: api::Api, const FOD: bool> Bitmap<Api, FOD> {
// TODO: investigate is it correct "res == 0 => Ok"
let f = self.1.set_bitmap_mask();
let res = unsafe { f(self.0, mask.0) };
if res == 0 {
Ok(())
} else {
Err(Error::InvalidMask)
}
if res == 0 { Ok(()) } else { Err(Error::InvalidMask) }
}

/// Gets a mask image for the given bitmap.
Expand Down
2 changes: 1 addition & 1 deletion api/sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-sys"
version = "0.2.8"
version = "0.2.9"
build = "src/build.rs"
readme = "README.md"
description = "Low-level Playdate API bindings"
Expand Down
5 changes: 4 additions & 1 deletion api/sys/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ fn main() {

let pdbindgen_found = Runner::find_tool(&cfg);
if cfg!(feature = "bindgen") && pdbindgen_found.is_some() {
println!("cargo:warning=Playdate bindgen found but also built as dependency of the {} by enabled feature 'bindgen'. You might want to disable that feature to significantly decrease build time.", pkg_name);
println!(
"cargo:warning=Playdate bindgen found but also built as dependency of the {} by enabled feature 'bindgen'. You might want to disable that feature to significantly decrease build time.",
pkg_name
);
// better wording: significantly speed up the compilation process?
}

Expand Down
16 changes: 2 additions & 14 deletions api/sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,11 @@ mod entry_point_ctrl {
}

impl From<bool> for EventLoopCtrl {
fn from(value: bool) -> Self {
if value {
Self::Continue
} else {
Self::Stop
}
}
fn from(value: bool) -> Self { if value { Self::Continue } else { Self::Stop } }
}

impl<T, E> From<Result<T, E>> for EventLoopCtrl {
fn from(res: Result<T, E>) -> Self {
if res.is_ok() {
Self::Continue
} else {
Self::Stop
}
}
fn from(res: Result<T, E>) -> Self { if res.is_ok() { Self::Continue } else { Self::Stop } }
}

#[cfg(feature = "try-trait-v2")]
Expand Down
2 changes: 1 addition & 1 deletion api/system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-system"
version = "0.3.7"
version = "0.3.8"
readme = "README.md"
description = "High-level System API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand Down
16 changes: 2 additions & 14 deletions api/system/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,11 @@ impl UpdateCtrl {
}

impl From<bool> for UpdateCtrl {
fn from(value: bool) -> Self {
if value {
Self::Continue
} else {
Self::Stop
}
}
fn from(value: bool) -> Self { if value { Self::Continue } else { Self::Stop } }
}

impl<T, E> From<Result<T, E>> for UpdateCtrl {
fn from(res: Result<T, E>) -> Self {
if res.is_ok() {
Self::Continue
} else {
Self::Stop
}
}
fn from(res: Result<T, E>) -> Self { if res.is_ok() { Self::Continue } else { Self::Stop } }
}

#[cfg(feature = "try-trait-v2")]
Expand Down
2 changes: 1 addition & 1 deletion cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-playdate"
version = "0.3.10"
version = "0.3.11"
readme = "README.md"
description = "Build tool for neat yellow console."
keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"]
Expand Down
47 changes: 24 additions & 23 deletions cargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,39 +464,40 @@ fn adapt_args_for_underlying_cargo<S, I>(cmd: &Cmd,
.collect();
let special_cases = matches!(cmd, Cmd::Run) && matches.get_raw("device").is_some();
let is_special_case = |id| id == "device" && matches!(cmd, Cmd::Run);
let specials_vals = specials_args.iter()
.flat_map(|arg| {
let max_values = if let Some(range) = arg.get_num_args() {
assert!(
let specials_vals =
specials_args.iter()
.flat_map(|arg| {
let max_values = if let Some(range) = arg.get_num_args() {
assert!(
arg.get_short().map(|_| range.max_values()).unwrap_or_default() == 0,
"special shorts should no require values, otherwise not implemented, {arg:?}"
);
assert!(
assert!(
range.min_values() == range.max_values() ||
is_special_case(arg.get_id().as_str()),
"special args should require exact values num, otherwise not implemented"
);
assert!(
assert!(
range.max_values() <= 1,
"special args should have 0..1 values, otherwise not implemented"
);
range.max_values()
} else {
0
};
assert!(
!arg.is_allow_hyphen_values_set(),
"special args should no allow hyphen values"
);
let mut all: Vec<_> = arg.get_all_aliases()
.unwrap_or_default()
.into_iter()
.map(ToOwned::to_owned)
.collect();
all.extend(arg.get_long().map(ToOwned::to_owned).into_iter());
all.into_iter().map(move |k| (k, max_values))
})
.collect::<HashMap<String, usize>>();
range.max_values()
} else {
0
};
assert!(
!arg.is_allow_hyphen_values_set(),
"special args should no allow hyphen values"
);
let mut all: Vec<_> = arg.get_all_aliases()
.unwrap_or_default()
.into_iter()
.map(ToOwned::to_owned)
.collect();
all.extend(arg.get_long().map(ToOwned::to_owned).into_iter());
all.into_iter().map(move |k| (k, max_values))
})
.collect::<HashMap<String, usize>>();


// insert targets:
Expand Down
13 changes: 3 additions & 10 deletions cargo/src/cli/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn flag_no_unwinding() -> Arg {
let name = "no-unwinding";
const SHORT: &str =
"Prevents unwinding, shorthand for `panic=abort` rustc flag and `panic_immediate_abort` feature.";
const LONG: &str ="Prevents unwinding. Adds `-Cpanic=abort` to `RUSTFLAGS` so that build profiles do not need to specify `panic = \"abort\"` in the cargo manifest. Also adds `-Zbuild-std-features=panic_immediate_abort` to ensure that there is no `core::panicking` in the product.";
const LONG: &str = "Prevents unwinding. Adds `-Cpanic=abort` to `RUSTFLAGS` so that build profiles do not need to specify `panic = \"abort\"` in the cargo manifest. Also adds `-Zbuild-std-features=panic_immediate_abort` to ensure that there is no `core::panicking` in the product.";
Arg::new(&name).long(&name)
.help(SHORT)
.long_help(LONG)
Expand All @@ -322,8 +322,7 @@ fn flag_no_unwinding() -> Arg {
fn flag_create_full_config() -> Arg {
let name = "full-config";
let help = format!("Create a full cargo config file with hardcoded link-paths that required to compile bin.");
let long =
format!("{help} Usually you don't need to use this flag when using {BIN_NAME} because {BIN_NAME} adds them itself when compiling.");
let long = format!("{help} Usually you don't need to use this flag when using {BIN_NAME} because {BIN_NAME} adds them itself when compiling.");
Arg::new(&name).long(&name)
.help(help)
.long_help(long)
Expand Down Expand Up @@ -496,13 +495,7 @@ fn usage() -> String {
include_str!("usage.txt"),
NAME = CMD_NAME,
BIN_NAME = BIN_NAME,
toolchain = {
if rustup.is_some() {
" [+toolchain]"
} else {
""
}
},
toolchain = { if rustup.is_some() { " [+toolchain]" } else { "" } },
toolchain_usage = {
if rustup.is_some() {
&toolchain_help
Expand Down
3 changes: 1 addition & 2 deletions cargo/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ fn package_multi_target<'p>(config: &Config,
let message = format!("Packaging more then two binaries for targets ({targets}) into one package can cause that some of them overwrite some other, so produced package can be broken.");
config.log().warn(message);

let message =
format!("Package can contains three binaries: one dylib for unix-family, one dll for windows and one elf for hardware.");
let message = format!("Package can contains three binaries: one dylib for unix-family, one dll for windows and one elf for hardware.");
config.log().note(message);

let error = format!("Can't mix two unix-family's dylibs into one package");
Expand Down
2 changes: 1 addition & 1 deletion support/tool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-tool"
version = "0.1.2"
version = "0.1.3"
readme = "README.md"
description = "Tool for interaction with Playdate device and sim."
keywords = ["playdate", "usb", "utility"]
Expand Down
6 changes: 1 addition & 5 deletions support/tool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ pub(crate) fn wait_for_mut<F: FnMut() -> bool>(mut f: F, delay: Duration, max: D
std::thread::sleep(delay);
}
}
if !res {
Err(Error::timeout())
} else {
Ok(())
}
if !res { Err(Error::timeout()) } else { Ok(()) }
}


Expand Down

0 comments on commit ccf6755

Please sign in to comment.