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 {
|
if key_str.len() == 1 {
|
||||||
keys.push_str(&key_str.to_uppercase());
|
keys.push_str(&key_str.to_uppercase());
|
||||||
} else {
|
} else {
|
||||||
if let Some(first_char) = key_str.chars().next() {
|
let mut chars = key_str.chars();
|
||||||
keys.push_str(&format!("{}{}", first_char.to_uppercase(), &key_str[1..]));
|
if let Some(first_char) = chars.next() {
|
||||||
|
keys.push_str(&format!(
|
||||||
|
"{}{}",
|
||||||
|
first_char.to_uppercase(),
|
||||||
|
chars.collect::<String>()
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
keys.push_str(&key_str);
|
keys.push_str(&key_str);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue