Skip to content

Commit

Permalink
Add ToArrayString for char
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed May 7, 2024
1 parent 36b5a89 commit c2adf56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ pub trait ToArrayString: Copy {
fn to_arraystring(self) -> Self::ArrayString;
}

impl ToArrayString for char {
type ArrayString = ArrayString<4>;

fn to_arraystring(self) -> Self::ArrayString {
let mut buffer = [0; 4];
let char_str = self.encode_utf8(&mut buffer);

ArrayString::from(char_str).unwrap()
}
}

impl ToArrayString for bool {
type ArrayString = ArrayString<5>;

Expand Down

0 comments on commit c2adf56

Please sign in to comment.