(&self, args: &[ScalarValue])
| 359 | } |
| 360 | |
| 361 | pub fn format(&self, args: &[ScalarValue]) -> Result<String> { |
| 362 | if args.len() < self.arg_num { |
| 363 | return exec_err!( |
| 364 | "Expected at least {} arguments, got {}", |
| 365 | self.arg_num, |
| 366 | args.len() |
| 367 | ); |
| 368 | } |
| 369 | let mut string = String::new(); |
| 370 | for element in &self.elements { |
| 371 | match element { |
| 372 | FormatElement::Verbatim(text) => { |
| 373 | string.push_str(text); |
| 374 | } |
| 375 | FormatElement::Format(spec) => { |
| 376 | spec.format(&mut string, &args[spec.argument_index - 1])?; |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | Ok(string) |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | #[derive(Debug)] |
no test coverage detected