xous: String: implement AsRef<str>

This allows xous Strings to be used in functions that expect to be able
to stringify arguments.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-03-26 12:31:59 +08:00
parent 0f455a9a02
commit 32ebee0b8f

View file

@ -223,6 +223,12 @@ impl<const N: usize> core::fmt::Debug for String<N> {
}
}
impl<const N: usize> core::convert::AsRef<str> for String<N> {
fn as_ref(&self) -> &str {
self.to_str()
}
}
#[repr(C)]
pub struct ArchivedString {
ptr: rkyv::RelPtr<str>,
@ -296,4 +302,4 @@ impl<const N: usize> Eq for String<N> {}
pub struct XousDeserializer;
impl rkyv::Fallible for XousDeserializer {
type Error = crate::Error;
}
}