]> git.lizzy.rs Git - rust.git/blob - src/libsyntax/print/helpers.rs
Auto merge of #62322 - wesleywiser:promoted_query, r=oli-obk
[rust.git] / src / libsyntax / print / helpers.rs
1 use std::borrow::Cow;
2 use crate::print::pp::Printer;
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() { self.space(); }
26     }
27
28     pub fn nbsp(&mut self) { self.word(" ") }
29
30     pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S) {
31         self.word(w);
32         self.nbsp()
33     }
34 }