kbd: Fix byte slice crash. (#1275)
This commit is contained in:
parent
455605d64b
commit
9febc52387
1 changed files with 7 additions and 2 deletions
|
|
@ -165,8 +165,13 @@ impl Kbd {
|
|||
if key_str.len() == 1 {
|
||||
keys.push_str(&key_str.to_uppercase());
|
||||
} else {
|
||||
if let Some(first_char) = key_str.chars().next() {
|
||||
keys.push_str(&format!("{}{}", first_char.to_uppercase(), &key_str[1..]));
|
||||
let mut chars = key_str.chars();
|
||||
if let Some(first_char) = chars.next() {
|
||||
keys.push_str(&format!(
|
||||
"{}{}",
|
||||
first_char.to_uppercase(),
|
||||
chars.collect::<String>()
|
||||
));
|
||||
} else {
|
||||
keys.push_str(&key_str);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue