From 915db44fbdabdb383e8e91f01c5a28386a2afa07 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 1 Apr 2023 19:15:39 +0200 Subject: [PATCH] Implement printf formatting for some parser types --- fish-rust/src/parse_constants.rs | 6 ++++++ fish-rust/src/tokenizer.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/fish-rust/src/parse_constants.rs b/fish-rust/src/parse_constants.rs index 895829015..7877a9f1e 100644 --- a/fish-rust/src/parse_constants.rs +++ b/fish-rust/src/parse_constants.rs @@ -322,6 +322,12 @@ impl From for &'static wstr { } } +impl printf_compat::args::ToArg<'static> for ParseKeyword { + fn to_arg(self) -> printf_compat::args::Arg<'static> { + printf_compat::args::Arg::Str(self.into()) + } +} + fn keyword_description(keyword: ParseKeyword) -> wcharz_t { let s: &'static wstr = keyword.into(); wcharz!(s) diff --git a/fish-rust/src/tokenizer.rs b/fish-rust/src/tokenizer.rs index 10d7fb16e..7461349f9 100644 --- a/fish-rust/src/tokenizer.rs +++ b/fish-rust/src/tokenizer.rs @@ -258,6 +258,12 @@ impl From for &'static wstr { } } +impl printf_compat::args::ToArg<'static> for TokenizerError { + fn to_arg(self) -> printf_compat::args::Arg<'static> { + printf_compat::args::Arg::Str(self.into()) + } +} + impl Tok { fn new(r#type: TokenType) -> Tok { Tok {