From 16ea102e94d6e96399c29f4e8c8b23e357e20df2 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 26 Mar 2021 17:09:16 +0800 Subject: [PATCH] xous: string: allow any stringlike thing to be used Anything that can be turned into a string can now be used in `from_str()`. Signed-off-by: Sean Cross --- xous-rs/src/string.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xous-rs/src/string.rs b/xous-rs/src/string.rs index 7be38f6f9..7e2129ff3 100644 --- a/xous-rs/src/string.rs +++ b/xous-rs/src/string.rs @@ -20,7 +20,8 @@ impl String { } } - pub fn from_str(src: &str) -> String { + pub fn from_str(src: T) -> String where T: AsRef { + let src = src.as_ref(); let mut s = Self::new(); // Copy the string into our backing store. for (&src_byte, dest_byte) in src.as_bytes().iter().zip(&mut s.bytes) {