From 52145c11628c569780907b4bbca296567df92ac4 Mon Sep 17 00:00:00 2001 From: Neeraj Panwar <49247372+npneeraj@users.noreply.github.com> Date: Sat, 18 Oct 2025 10:34:14 +0530 Subject: [PATCH 1/2] Refine from_f function documentation and add tests Updated documentation and added tests for from_f function. --- src/event/key.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/event/key.rs b/src/event/key.rs index c81ffed..5c58b3e 100755 --- a/src/event/key.rs +++ b/src/event/key.rs @@ -72,7 +72,7 @@ impl Key { /// /// # Panics /// - /// If `n == 0 || n > 12` + /// If `n > 12` pub fn from_f(n: u8) -> Key { match n { 0 => Key::F0, @@ -252,4 +252,14 @@ mod tests { Key::Ctrl('c') ); } + #[test] + fn from_f_zero_is_valid() { + assert_eq!(Key::from_f(0), Key::F0); + } + + #[test] + #[should_panic(expected = "unknown function key: F13")] + fn from_f_above_max_panics() { + let _ = Key::from_f(13); + } } From cb9c302f6af96a27ddccabbe13ef432fe5b655cd Mon Sep 17 00:00:00 2001 From: Neeraj Panwar <49247372+npneeraj@users.noreply.github.com> Date: Sun, 26 Oct 2025 23:33:43 +0530 Subject: [PATCH 2/2] Update src/event/key.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Orhun Parmaksız --- src/event/key.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/event/key.rs b/src/event/key.rs index 5c58b3e..7524cc1 100755 --- a/src/event/key.rs +++ b/src/event/key.rs @@ -252,6 +252,7 @@ mod tests { Key::Ctrl('c') ); } + #[test] fn from_f_zero_is_valid() { assert_eq!(Key::from_f(0), Key::F0);