(
&self,
string: T,
precision: Option<&CFormatPrecision>,
)
| 375 | } |
| 376 | |
| 377 | fn format_string_with_precision<T: FormatBuf>( |
| 378 | &self, |
| 379 | string: T, |
| 380 | precision: Option<&CFormatPrecision>, |
| 381 | ) -> T { |
| 382 | // truncate if needed |
| 383 | let string = match precision { |
| 384 | Some(CFormatPrecision::Quantity(CFormatQuantity::Amount(precision))) |
| 385 | if string.chars().count() > *precision => |
| 386 | { |
| 387 | string.chars().take(*precision).collect::<T>() |
| 388 | } |
| 389 | Some(CFormatPrecision::Dot) => { |
| 390 | // truncate to 0 |
| 391 | T::default() |
| 392 | } |
| 393 | _ => string, |
| 394 | }; |
| 395 | self.fill_string(string, b' '.into(), None) |
| 396 | } |
| 397 | |
| 398 | #[inline] |
| 399 | pub fn format_string<T: FormatBuf>(&self, string: T) -> T { |
no test coverage detected