diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-02-20 15:49:34 +0100 |
---|---|---|
committer | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-30 13:52:31 +0200 |
commit | 541c0f009c6c21223942ca7f3157976701f7db8c (patch) | |
tree | 5ee7767ea9eb1ee3a76add8d5d4bfef8e2c1f361 | |
parent | fa88446bd539415fcb8301ba25048f8499422c88 (diff) | |
download | gcc-541c0f009c6c21223942ca7f3157976701f7db8c.zip gcc-541c0f009c6c21223942ca7f3157976701f7db8c.tar.gz gcc-541c0f009c6c21223942ca7f3157976701f7db8c.tar.bz2 |
libproc_macro: Implement Display for Punct
Implement the Display trait for the rust internal Punct structure.
ChangeLog:
* librust/proc_macro/rust/bridge/punct.rs: Implement Display.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | librust/proc_macro/rust/bridge/punct.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/librust/proc_macro/rust/bridge/punct.rs b/librust/proc_macro/rust/bridge/punct.rs index 20b03c5..f5f76b1 100644 --- a/librust/proc_macro/rust/bridge/punct.rs +++ b/librust/proc_macro/rust/bridge/punct.rs @@ -1,4 +1,6 @@ use bridge::span::Span; +use std::convert::TryFrom; +use std::fmt; use Spacing; #[repr(C)] @@ -24,3 +26,12 @@ impl Punct { let _ = span; } } + +impl fmt::Display for Punct { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Spacing::Alone = self.spacing { + f.write_str(" ")?; + } + char::try_from(self.ch).unwrap().fmt(f) + } +} |