Skip to content

Commit

Permalink
docs: Make empty listener panic clearer
Browse files Browse the repository at this point in the history
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 <dev@notgull.net>
  • Loading branch information
notgull committed Mar 28, 2024
1 parent 8f11a87 commit 58dbfc8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ impl<T> RegisterResult<T> {
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),
}
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 58dbfc8

Please sign in to comment.