Skip to content

Commit

Permalink
feat: add pretty-print helper for lists of values
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Aug 3, 2024
1 parent 011a1e0 commit 7d1e58b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ pub use math::{

pub mod prettier {
pub use miden_formatting::{prettier::*, pretty_via_display, pretty_via_to_string};

/// Pretty-print a list of [PrettyPrint] values as comma-separated items.
pub fn pretty_print_csv<'a, T>(items: impl IntoIterator<Item = &'a T>) -> Document
where
T: PrettyPrint + 'a,
{
let mut doc = Document::Empty;
for (i, item) in items.into_iter().enumerate() {
if i > 0 {
doc += const_text(", ");
}
doc += item.render();
}
doc
}
}

mod operations;
Expand Down

0 comments on commit 7d1e58b

Please sign in to comment.