Skip to content

Commit

Permalink
(0.4.2) formatters: accept into iterator of token refs
Browse files Browse the repository at this point in the history
  • Loading branch information
sameer committed Apr 6, 2024
1 parent 1c0b495 commit 97c8180
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "g-code"
version = "0.4.1"
version = "0.4.2"
authors = ["Sameer Puri <crates@purisa.me>"]
edition = "2021"
keywords = ["gcode", "g-code", "plotter", "cnc"]
Expand Down
12 changes: 6 additions & 6 deletions lib/src/emit/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct FormatOptions {
}

macro_rules! formatter_core {
($program: ident, $opts: ident, $downstream: ident) => {
($program: expr, $opts: ident, $downstream: ident) => {
use Token::*;
let mut preceded_by_newline = true;
let mut line_number = 0usize;
Expand Down Expand Up @@ -151,28 +151,28 @@ macro_rules! formatter_core {
}

/// Write GCode tokens to an [IoWrite] in a nicely formatted manner
pub fn format_gcode_io<'a, W>(
program: impl Iterator<Item = Token<'a>>,
pub fn format_gcode_io<'a: 'b, 'b, W>(
program: impl IntoIterator<Item = &'b Token<'a>>,
opts: FormatOptions,
w: W,
) -> std::io::Result<()>
where
W: IoWrite,
{
formatter_core!(program, opts, w);
formatter_core!(program.into_iter(), opts, w);
Ok(())
}

/// Write formatted GCode to a [FmtWrite] in a nicely formatted manner
pub fn format_gcode_fmt<'a: 'b, 'b, W>(
program: impl Iterator<Item = &'b Token<'a>>,
program: impl IntoIterator<Item = &'b Token<'a>>,
opts: FormatOptions,
w: W,
) -> fmt::Result
where
W: FmtWrite,
{
formatter_core!(program, opts, w);
formatter_core!(program.into_iter(), opts, w);
Ok(())
}

Expand Down

0 comments on commit 97c8180

Please sign in to comment.