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 <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-03-26 17:09:16 +08:00
parent af5598d2dc
commit 16ea102e94

View file

@ -20,7 +20,8 @@ impl<const N: usize> String<N> {
}
}
pub fn from_str(src: &str) -> String<N> {
pub fn from_str<T>(src: T) -> String<N> where T: AsRef<str> {
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) {