public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] libproc_macro: Implement Display for Punct
@ 2023-04-06 21:31 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:31 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:541c0f009c6c21223942ca7f3157976701f7db8c
commit 541c0f009c6c21223942ca7f3157976701f7db8c
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Mon Feb 20 15:49:34 2023 +0100
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>
Diff:
---
librust/proc_macro/rust/bridge/punct.rs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/librust/proc_macro/rust/bridge/punct.rs b/librust/proc_macro/rust/bridge/punct.rs
index 20b03c58101..f5f76b1f1cf 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)
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 21:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:31 [gcc/devel/rust/master] libproc_macro: Implement Display for Punct Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).