From 5cc74438a823dd432d9dae1411f14d612e84471b Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Sun, 13 Oct 2024 16:13:26 -0700 Subject: [PATCH] Adjust some internal docs --- manul/src/protocol/object_safe.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/manul/src/protocol/object_safe.rs b/manul/src/protocol/object_safe.rs index fc898a4..c0c4760 100644 --- a/manul/src/protocol/object_safe.rs +++ b/manul/src/protocol/object_safe.rs @@ -75,12 +75,10 @@ pub(crate) trait ObjectSafeRound: 'static + Send + Sync { fn expecting_messages_from(&self) -> &BTreeSet; /// Returns the type ID of the implementing type. - /// - /// **Warning:** this is not a part of the public API. - #[doc(hidden)] - fn __get_type_id(&self) -> core::any::TypeId; + fn get_type_id(&self) -> core::any::TypeId; } +// The `fn(Id) -> Id` bit is so that `ObjectSafeRoundWrapper` didn't require a bound on `Id` to be `Send + Sync`. pub(crate) struct ObjectSafeRoundWrapper { round: R, phantom: PhantomData Id>, @@ -154,8 +152,7 @@ where self.round.expecting_messages_from() } - #[doc(hidden)] - fn __get_type_id(&self) -> core::any::TypeId { + fn get_type_id(&self) -> core::any::TypeId { core::any::TypeId::of::() } } @@ -173,7 +170,8 @@ where P: 'static + Protocol, { pub fn try_downcast>(self: Box) -> Result> { - if core::any::TypeId::of::>() == self.__get_type_id() { + if core::any::TypeId::of::>() == self.get_type_id() { + // This should be safe since we just checked that we are casting to a correct type. let boxed_downcast = unsafe { Box::>::from_raw(Box::into_raw(self) as *mut ObjectSafeRoundWrapper) };