mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Merge #11925
11925: internal: Add and use `HirFormatter::write_{str,char}` r=Veykril a=lnicola Saves slightly over 3 KB of `text`, but comparing the total with that from two weeks ago in #11776, this is a losing battle (we're 951 KB larger). ``` text data bss dec hex filename 24693512 1542704 4424 26240640 1906680 rust-analyzer-baseline 24690216 1542112 4424 26236752 1905750 rust-analyzer-pr ``` Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
12f803d1e3
2 changed files with 64 additions and 55 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue