rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: kernel: str: Implement Debug for CString
@ 2023-07-14  9:19 Asahi Lina
  2023-07-14  9:48 ` Alice Ryhl
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Asahi Lina @ 2023-07-14  9:19 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin
  Cc: rust-for-linux, linux-kernel, asahi, Asahi Lina

Trivial implementation.

Signed-off-by: Asahi Lina <lina@asahilina.net>
---
 rust/kernel/str.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index c9dd3bf59e34..a94e396d39e1 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -606,6 +606,12 @@ fn try_from(cstr: &'a CStr) -> Result<CString, AllocError> {
     }
 }
 
+impl fmt::Debug for CString {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt::Debug::fmt(&**self, f)
+    }
+}
+
 /// A convenience alias for [`core::format_args`].
 #[macro_export]
 macro_rules! fmt {

---
base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
change-id: 20230714-cstring-debug-ca021fe0ad78

Thank you,
~~ Lina


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-12-13 18:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-14  9:19 [PATCH] rust: kernel: str: Implement Debug for CString Asahi Lina
2023-07-14  9:48 ` Alice Ryhl
2023-07-14 12:21   ` Asahi Lina
2023-07-14 13:46     ` Martin Rodriguez Reboredo
2023-07-14 10:05 ` Ariel Miculas
2023-07-14 14:02   ` Alice Ryhl
2023-07-14 15:01     ` Miguel Ojeda
2023-10-25 16:18       ` Ariel Miculas (amiculas)
2023-10-25 16:55         ` Miguel Ojeda
2023-07-15 10:00 ` Benno Lossin
2023-12-13 18:43 ` Miguel Ojeda

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 NNTP newsgroup(s).