summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-16 13:31:02 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-16 13:31:02 +0100
commit03f5a351c37dbe1b0a286583e620d1cf074f1b91 (patch)
tree8cd9894a0a7d83664fd662de0533df21b481c397
parent64d1ce5532f55d152fa5819532a138da2dca1a39 (diff)
downloadiced-03f5a351c37dbe1b0a286583e620d1cf074f1b91.tar.gz
iced-03f5a351c37dbe1b0a286583e620d1cf074f1b91.tar.bz2
iced-03f5a351c37dbe1b0a286583e620d1cf074f1b91.zip
Use `SmolStr` for `text` field in `KeyPressed` event
-rw-r--r--core/src/keyboard/event.rs3
-rw-r--r--core/src/keyboard/key.rs2
-rw-r--r--core/src/lib.rs2
-rw-r--r--winit/src/conversion.rs4
4 files changed, 6 insertions, 5 deletions
diff --git a/core/src/keyboard/event.rs b/core/src/keyboard/event.rs
index b1792415..1eb42334 100644
--- a/core/src/keyboard/event.rs
+++ b/core/src/keyboard/event.rs
@@ -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.
diff --git a/core/src/keyboard/key.rs b/core/src/keyboard/key.rs
index ef48dae4..dbde5196 100644
--- a/core/src/keyboard/key.rs
+++ b/core/src/keyboard/key.rs
@@ -1,5 +1,5 @@
//! Identify keyboard keys.
-use smol_str::SmolStr;
+use crate::SmolStr;
/// A key on the keyboard.
///
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 54ea5839..864df6e6 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -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;
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 387289e8..90a5d27f 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -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 => {