From 395e1ce48b1adbf6f0d8b8e0da503a6a81d8f1c4 Mon Sep 17 00:00:00 2001 From: AsterixxxGallier Date: Fri, 23 Aug 2024 19:23:36 +0300 Subject: [PATCH] Document World::try_add_handler --- src/world.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/world.rs b/src/world.rs index 585386e..d3d18b3 100644 --- a/src/world.rs +++ b/src/world.rs @@ -316,6 +316,14 @@ impl World { Some(unsafe { &mut *col.data().as_ptr().cast::().add(loc.row.0 as usize) }) } + /// Adds a new handler to the world, returns its [`HandlerId`], and sends + /// the [`AddHandler`] event to signal its creation. + /// + /// If the handler already exists (as determined by [`Handler::type_id`]) + /// then the `HandlerId` of the existing handler is returned and no + /// event is sent. + /// + /// Returns an error if the configuration of the handler is invalid. pub(crate) fn try_add_handler, M>( &mut self, handler: H, @@ -1205,7 +1213,7 @@ impl Default for World { } } -/// Reference to a [`World`] where all methods take `&self` and aliasing rules +/// Reference to a [`World`] where all methods take `self` and aliasing rules /// are not checked. It is the caller's responsibility to ensure that Rust's /// aliasing rules are not violated. #[derive(Clone, Copy, Debug)]