Export smol_str and impl Ord for Key

Fixes #2996.
This commit is contained in:
Diggory Hardy 2023-08-03 17:12:48 +01:00 committed by GitHub
parent b5aa96bea4
commit 189a0080a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -1019,6 +1019,13 @@ pub enum ElementState {
Released,
}
impl ElementState {
/// True if `self == Pressed`.
pub fn is_pressed(self) -> bool {
self == ElementState::Pressed
}
}
/// Describes a button of a mouse controller.
///
/// ## Platform-specific

View file

@ -69,7 +69,7 @@
//
// --------- END OF W3C SHORT NOTICE ---------------------------------------------------------------
use smol_str::SmolStr;
pub use smol_str::SmolStr;
/// Contains the platform-native physical key identifier
///
@ -135,7 +135,7 @@ impl std::fmt::Debug for NativeKeyCode {
/// This enum is primarily used to store raw keysym when Winit doesn't map a given native logical
/// key identifier to a meaningful [`Key`] variant. This lets you use [`Key`], and let the user
/// define keybinds which work in the presence of identifiers we haven't mapped for you yet.
#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum NativeKey {
Unidentified,
@ -662,7 +662,7 @@ pub enum KeyCode {
///
/// [`KeyboardEvent.key`]: https://w3c.github.io/uievents-key/
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Key<Str = SmolStr> {
/// A key string that corresponds to the character typed by the user, taking into account the