From 2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Sun, 31 May 2026 02:42:52 +0800 Subject: Enhance code quality across the entire codebase --- mingling_core/src/any.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'mingling_core/src/any.rs') diff --git a/mingling_core/src/any.rs b/mingling_core/src/any.rs index 3dedea4..46ebced 100644 --- a/mingling_core/src/any.rs +++ b/mingling_core/src/any.rs @@ -10,7 +10,7 @@ pub mod group; /// Any type output /// /// Accepts any type that implements `Send + Groupped` -/// After being passed into AnyOutput, it will be converted to `Box` +/// After being passed into `AnyOutput`, it will be converted to `Box` /// /// Note: /// - If an enum value that does not belong to this type is incorrectly specified, it will be **unsafely** unwrapped by the scheduler @@ -24,7 +24,7 @@ pub struct AnyOutput { } impl AnyOutput { - /// Create an AnyOutput from a `Send + Groupped + Serialize` type + /// Create an `AnyOutput` from a `Send + Groupped + Serialize` type #[cfg(feature = "general_renderer")] pub fn new(value: T) -> Self where @@ -37,7 +37,7 @@ impl AnyOutput { } } - /// Create an AnyOutput from a `Send + Groupped` type + /// Create an `AnyOutput` from a `Send + Groupped` type #[cfg(not(feature = "general_renderer"))] pub fn new(value: T) -> Self where @@ -50,7 +50,15 @@ impl AnyOutput { } } - /// Downcast the AnyOutput to a concrete type T + /// Attempt to downcast the `AnyOutput` to a concrete type. + /// + /// # Errors + /// + /// Returns `Err(self)` if the downcast fails. + /// + /// # Panics + /// + /// Panics if the inner value is not of type `T`. pub fn downcast(self) -> Result { if self.type_id == std::any::TypeId::of::() { Ok(*self.inner.downcast::().unwrap()) @@ -75,7 +83,7 @@ impl AnyOutput { } #[cfg(feature = "general_renderer")] - /// Restore AnyOutput back to the original Serialize type + /// Restore `AnyOutput` back to the original Serialize type pub fn restore(self) -> Option { if self.type_id == std::any::TypeId::of::() { match self.inner.downcast::() { -- cgit