From 58dbfc8bc545207ebe452eb346f892bddc1f35bc Mon Sep 17 00:00:00 2001 From: John Nunley Date: Mon, 25 Mar 2024 21:13:08 -0700 Subject: [PATCH] docs: Make empty listener panic clearer This commit makes the panic message for a listener that's not inserted into the linked list much clearer. The goal is to convey to the user that they may be `poll`ing the listener after it has completed. This commit also fixes some new Clippy lints. cc #124 Signed-off-by: John Nunley --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b8b6e6b..e6123a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1248,7 +1248,7 @@ impl RegisterResult { match self { Self::Notified(tag) => Some(tag), Self::Registered => None, - Self::NeverInserted => panic!("listener was never inserted into the list"), + Self::NeverInserted => panic!("{}", NEVER_INSERTED_PANIC), } } } @@ -1326,6 +1326,10 @@ impl TaskRef<'_> { } } +const NEVER_INSERTED_PANIC: &str = "\ +EventListener was not inserted into the linked list, make sure you're not polling \ +EventListener/listener! after it has finished"; + /// Synchronization primitive implementation. mod sync { pub(super) use core::cell;