Use SmolStr for text field in KeyPressed event

This commit is contained in:
Héctor Ramón Jiménez 2024-01-16 13:31:02 +01:00
parent 64d1ce5532
commit 03f5a351c3
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 6 additions and 5 deletions

View file

@ -1,4 +1,5 @@
use crate::keyboard::{Key, Location, Modifiers};
use crate::SmolStr;
/// A keyboard event.
///
@ -20,7 +21,7 @@ pub enum Event {
modifiers: Modifiers,
/// The text produced by the key press, if any.
text: Option<String>,
text: Option<SmolStr>,
},
/// A keyboard key was released.

View file

@ -1,5 +1,5 @@
//! Identify keyboard keys.
use smol_str::SmolStr;
use crate::SmolStr;
/// A key on the keyboard.
///

View file

@ -75,3 +75,5 @@ pub use size::Size;
pub use text::Text;
pub use vector::Vector;
pub use widget::Widget;
pub use smol_str::SmolStr;

View file

@ -225,9 +225,7 @@ pub fn window_event(
key,
modifiers,
location,
text: text
.as_ref()
.map(winit::keyboard::SmolStr::to_string),
text,
}
}
winit::event::ElementState::Released => {