Skip to content

Commit

Permalink
"close" is a better name for this
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshkukreti committed Feb 4, 2024
1 parent a4dfbfd commit 704cd6f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ fn main() {
diff::chars(&left, &right)
};

let mut open = None;
let mut close = None;

for d in diff {
match (d, open) {
match (d, close) {
(diff::Result::Left(l), Some("-]")) => print!("{}", l),
(diff::Result::Left(l), open_) => {
print!("{}[-{}", open_.unwrap_or(""), l);
open = Some("-]");
close = Some("-]");
}
(diff::Result::Right(r), Some("+}")) => print!("{}", r),
(diff::Result::Right(r), open_) => {
print!("{}{{+{}", open_.unwrap_or(""), r);
open = Some("+}");
close = Some("+}");
}
(diff::Result::Both(l, _), Some(open_)) => {
print!("{}{}", open_, l);
open = None;
close = None;
}
(diff::Result::Both(l, _), None) => print!("{}", l),
}
Expand Down

0 comments on commit 704cd6f

Please sign in to comment.