Skip to content

Commit

Permalink
Add dependencies and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Enter-tainer committed Nov 19, 2023
1 parent b108d6f commit 3b65c6c
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 518 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
*.log
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "1.0.50"
typst-syntax = { git = "https://github.com/typst/typst.git", tag = "v0.9.0" }

[dev-dependencies]
insta = "1.34.0"
insta = { version = "1.34.0", features = ["yaml"] }

[build-dependencies]
anyhow = "1.0.75"
Expand All @@ -36,3 +36,7 @@ vergen = { version = "8.2.5", features = [
"git2",
"rustc",
] }

[profile.dev.package]
insta.opt-level = 3
similar.opt-level = 3
9 changes: 5 additions & 4 deletions examples/pretty_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use pretty::BoxDoc;

fn main() {
let strs = ["123", "12345", "1234", "1234567"];

let inner_flat: BoxDoc<'_, ()> = BoxDoc::intersperse(
strs.into_iter().map(BoxDoc::text),
BoxDoc::text(",").append(BoxDoc::space()),
);

let inner_multi = {
let mut inner = BoxDoc::nil();
for s in strs {
Expand All @@ -18,14 +18,15 @@ fn main() {
BoxDoc::line().append(inner)
}
.nest(2);

let outer = BoxDoc::text("[")
.append(inner_multi.flat_alt(inner_flat).group())
// https://hackage.haskell.org/package/prettyprinter-1.7.1/docs/Prettyprinter.html#v:group
.append(BoxDoc::text("]"));

let res_10 = outer.pretty(10).to_string();
let res_80 = outer.pretty(80).to_string();

println!("10:\n{}", res_10);
println!("80:\n{}", res_80);
}
Loading

0 comments on commit 3b65c6c

Please sign in to comment.