]> git.lizzy.rs Git - rust.git/blob - src/librustc_ast_pretty/helpers.rs
Rollup merge of #67642 - Mark-Simulacrum:relax-bounds, r=Amanieu
[rust.git] / src / librustc_ast_pretty / helpers.rs
1 use crate::pp::Printer;
2 use std::borrow::Cow;
3
4 impl Printer {
5     pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
6         self.word(w);
7         self.space();
8     }
9
10     pub fn popen(&mut self) {
11         self.word("(");
12     }
13
14     pub fn pclose(&mut self) {
15         self.word(")");
16     }
17
18     pub fn hardbreak_if_not_bol(&mut self) {
19         if !self.is_beginning_of_line() {
20             self.hardbreak()
21         }
22     }
23
24     pub fn space_if_not_bol(&mut self) {
25         if !self.is_beginning_of_line() {
26             self.space();
27         }
28     }
29
30     pub fn nbsp(&mut self) {
31         self.word(" ")
32     }
33
34     pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S) {
35         self.word(w);
36         self.nbsp()
37     }
38 }