(
&self,
string: T,
fill_char: T::Char,
num_prefix_chars: Option<usize>,
)
| 323 | } |
| 324 | |
| 325 | fn fill_string<T: FormatBuf>( |
| 326 | &self, |
| 327 | string: T, |
| 328 | fill_char: T::Char, |
| 329 | num_prefix_chars: Option<usize>, |
| 330 | ) -> T { |
| 331 | let mut num_chars = string.chars().count(); |
| 332 | if let Some(num_prefix_chars) = num_prefix_chars { |
| 333 | num_chars += num_prefix_chars; |
| 334 | } |
| 335 | let num_chars = num_chars; |
| 336 | |
| 337 | let width = match &self.min_field_width { |
| 338 | Some(CFormatQuantity::Amount(width)) => cmp::max(width, &num_chars), |
| 339 | _ => &num_chars, |
| 340 | }; |
| 341 | let fill_chars_needed = width.saturating_sub(num_chars); |
| 342 | let fill_string: T = Self::compute_fill_string(fill_char, fill_chars_needed); |
| 343 | |
| 344 | if !fill_string.is_empty() { |
| 345 | if self.flags.contains(CConversionFlags::LEFT_ADJUST) { |
| 346 | string.concat(fill_string) |
| 347 | } else { |
| 348 | fill_string.concat(string) |
| 349 | } |
| 350 | } else { |
| 351 | string |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | fn fill_string_with_precision<T: FormatBuf>(&self, string: T, fill_char: T::Char) -> T { |
| 356 | let num_chars = string.chars().count(); |
no test coverage detected