From 32ebee0b8f10c9455c35f534138716fa7d3dda3b Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 26 Mar 2021 12:31:59 +0800 Subject: [PATCH] xous: String: implement AsRef This allows xous Strings to be used in functions that expect to be able to stringify arguments. Signed-off-by: Sean Cross --- xous-rs/src/string.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xous-rs/src/string.rs b/xous-rs/src/string.rs index f2c0f5c51..7be38f6f9 100644 --- a/xous-rs/src/string.rs +++ b/xous-rs/src/string.rs @@ -223,6 +223,12 @@ impl core::fmt::Debug for String { } } +impl core::convert::AsRef for String { + fn as_ref(&self) -> &str { + self.to_str() + } +} + #[repr(C)] pub struct ArchivedString { ptr: rkyv::RelPtr, @@ -296,4 +302,4 @@ impl Eq for String {} pub struct XousDeserializer; impl rkyv::Fallible for XousDeserializer { type Error = crate::Error; -} \ No newline at end of file +}