Skip to content

Commit 40d07eb

Browse files
committed
Hide turnstile when not needed
1 parent 2cd19c9 commit 40d07eb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/ast/printer.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ impl<'a> TypingPredicate<'a> {
221221
.to_display_tree(a)
222222
.sep_then(a, ": ", ty);
223223

224-
pre_turnstile.sep_then(a, " ⊢ ", post_turnstile)
224+
let parts: &[_] = if pre_turnstile.is_empty() {
225+
&[post_turnstile]
226+
} else {
227+
&[pre_turnstile, post_turnstile]
228+
};
229+
DisplayTree::sep_by(a, " ⊢ ", parts)
225230
}
226231
}
227232
}

src/ast/printer/display_tree.rs

+7
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ fn strip_markup(s: &str) -> String {
7777
}
7878

7979
impl<'a> DisplayTree<'a> {
80+
pub fn is_empty(&self) -> bool {
81+
match self.kind {
82+
Leaf(s) => s.is_empty(),
83+
Separated { children, .. } => children.is_empty(),
84+
}
85+
}
86+
8087
pub fn len_ignoring_markup(&self) -> usize {
8188
match self.kind {
8289
Leaf(s) => len_ignoring_markup(s),

0 commit comments

Comments
 (0)