Add and use HirFormatter::write_{str,char}

This commit is contained in:
Laurențiu Nicola 2022-04-07 16:41:07 +03:00
parent f4e4a3a896
commit bd570903b0
2 changed files with 64 additions and 55 deletions

View file

@ -172,6 +172,16 @@ impl<'a> HirFormatter<'a> {
self.fmt.write_str(&self.buf).map_err(HirDisplayError::from)
}
pub fn write_str(&mut self, s: &str) -> Result<(), HirDisplayError> {
self.fmt.write_str(s)?;
Ok(())
}
pub fn write_char(&mut self, c: char) -> Result<(), HirDisplayError> {
self.fmt.write_char(c)?;
Ok(())
}
pub fn should_truncate(&self) -> bool {
match self.max_size {
Some(max_size) => self.curr_size >= max_size,