mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
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:
parent
af5598d2dc
commit
16ea102e94
1 changed files with 2 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue