Skip to content

Constructing Key::Character(_) without importing Smolstr #2996

@dhardy

Description

@dhardy

Currently to construct a Key::Character(_) I have to:

  1. Import Smolstr
  2. Do e.g. Key::Character(SmolStr::new_inline("/"))

Since Winit includes Smolstr in its public API, I recommend that it be publically re-export (e.g. winit::keyboard::Smolstr) so that users do not have to add a dependency on (the correct version of) this crate too.

Further, I suggest adding convenience constructors. Some ideas:

-fn Key::new_char(c: char) -> Option<Self> — note that control characters are not allowed

  • fn Key::new_str(s: impl AsRef<str>) -> Option<Self>
  • fn Key::new_str_inline(s: &str) -> Option<Self> — uses SmolStr::new_inline

Since Key::Character is not a char maybe it has the wrong name? (I bet there's already far too much discussion on that topic.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions