Skip to content

Commit

Permalink
Merge pull request #214 from epage/template
Browse files Browse the repository at this point in the history
chore: Update from _rust template
  • Loading branch information
epage authored Sep 27, 2024
2 parents c2ee0d9 + deb03c0 commit 1352d11
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: pre-commit/action@v3.0.1
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp
PRs should tell a cohesive story, with test and refactor commits that keep the
fix or feature commits simple and clear.

Specifically, we would encouage
Specifically, we would encourage
- File renames be isolated into their own commit
- Add tests in a commit before their feature or fix, showing the current behavior.
The diff for the feature/fix commit will then show how the behavior changed,
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
uninlined_format_args = "warn"
verbose_file_reads = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
2 changes: 1 addition & 1 deletion crates/anstream/src/adapter/strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'s> StrippedStr<'s> {
pub fn to_string(&self) -> String {
use std::fmt::Write as _;
let mut stripped = String::with_capacity(self.bytes.len());
let _ = write!(&mut stripped, "{}", self);
let _ = write!(&mut stripped, "{self}");
stripped
}
}
Expand Down
6 changes: 2 additions & 4 deletions crates/anstyle-git/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,13 @@ impl std::fmt::Display for Error {
Self::ExtraColor { style, word } => {
write!(
fmt,
"Error parsing style \"{}\": extra color \"{}\"",
style, word
"Error parsing style \"{style}\": extra color \"{word}\""
)
}
Self::UnknownWord { style, word } => {
write!(
fmt,
"Error parsing style \"{}\": unknown word: \"{}\"",
style, word
"Error parsing style \"{style}\": unknown word: \"{word}\""
)
}
}
Expand Down
22 changes: 8 additions & 14 deletions crates/anstyle-parse/examples/parselog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,40 @@ struct Log;

impl Perform for Log {
fn print(&mut self, c: char) {
println!("[print] {:?}", c);
println!("[print] {c:?}");
}

fn execute(&mut self, byte: u8) {
println!("[execute] {:02x}", byte);
println!("[execute] {byte:02x}");
}

fn hook(&mut self, params: &Params, intermediates: &[u8], ignore: bool, c: u8) {
println!(
"[hook] params={:?}, intermediates={:?}, ignore={:?}, char={:?}",
params, intermediates, ignore, c
"[hook] params={params:?}, intermediates={intermediates:?}, ignore={ignore:?}, char={c:?}"
);
}

fn put(&mut self, byte: u8) {
println!("[put] {:02x}", byte);
println!("[put] {byte:02x}");
}

fn unhook(&mut self) {
println!("[unhook]");
}

fn osc_dispatch(&mut self, params: &[&[u8]], bell_terminated: bool) {
println!(
"[osc_dispatch] params={:?} bell_terminated={}",
params, bell_terminated
);
println!("[osc_dispatch] params={params:?} bell_terminated={bell_terminated}");
}

fn csi_dispatch(&mut self, params: &Params, intermediates: &[u8], ignore: bool, c: u8) {
println!(
"[csi_dispatch] params={:#?}, intermediates={:?}, ignore={:?}, char={:?}",
params, intermediates, ignore, c
"[csi_dispatch] params={params:#?}, intermediates={intermediates:?}, ignore={ignore:?}, char={c:?}"
);
}

fn esc_dispatch(&mut self, intermediates: &[u8], ignore: bool, byte: u8) {
println!(
"[esc_dispatch] intermediates={:?}, ignore={:?}, byte={:02x}",
intermediates, ignore, byte
"[esc_dispatch] intermediates={intermediates:?}, ignore={ignore:?}, byte={byte:02x}"
);
}
}
Expand All @@ -70,7 +64,7 @@ fn main() {
}
}
Err(err) => {
println!("err: {}", err);
println!("err: {err}");
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/anstyle-parse/src/state/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pub(crate) const STATE_CHANGES: [[u8; 256]; 16] = ["#
let (next_state, action) = unpack(*packed);
if last_entry != Some(packed) {
writeln!(file)?;
writeln!(file, " // {:?} {:?}", next_state, action)?;
writeln!(file, " // {next_state:?} {action:?}")?;
write!(file, " ")?;
}
write!(file, "0x{:0>2x}, ", packed)?;
write!(file, "0x{packed:0>2x}, ")?;
last_entry = Some(packed);
}
writeln!(file)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/anstyle-roff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn rgb_name(c: &RgbColor) -> String {

fn to_hex(rgb: &RgbColor) -> String {
let val: usize = ((rgb.0 as usize) << 16) + ((rgb.1 as usize) << 8) + (rgb.2 as usize);
format!("#{:06x}", val)
format!("#{val:06x}")
}

/// Map Color and Bright Variants to Roff Color styles
Expand Down
2 changes: 1 addition & 1 deletion crates/anstyle-wincon/examples/dump-wincon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn print_number(
});

stdout
.write_colored(fg, bg, format!("{:>3X}", fixed).as_bytes())
.write_colored(fg, bg, format!("{fixed:>3X}").as_bytes())
.map(|_| ())
}

Expand Down

0 comments on commit 1352d11

Please sign in to comment.