Skip to content

Commit 210d1a8

Browse files
committed
Add impl From<NamedKey> for Key
1 parent 7634834 commit 210d1a8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ impl FromStr for Key {
198198
}
199199
}
200200

201+
impl From<NamedKey> for Key {
202+
fn from(value: NamedKey) -> Self {
203+
Self::Named(value)
204+
}
205+
}
206+
201207
impl Key {
202208
/// Determine a *charCode* value for a key with a character value.
203209
///
@@ -319,4 +325,9 @@ mod test {
319325
assert!(!is_key_string("AA"));
320326
assert!(!is_key_string(" "));
321327
}
328+
329+
#[test]
330+
fn into() {
331+
assert_eq!(Key::Named(NamedKey::Enter), NamedKey::Enter.into());
332+
}
322333
}

0 commit comments

Comments
 (0)