diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-31 02:42:52 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-31 17:19:20 +0800 |
| commit | 2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 (patch) | |
| tree | f10b89007fc67ca1a948f34abe6869b49296b932 /mingling_core/src/any.rs | |
| parent | 3aa409a55e4f2f0ab41b0949cc06eb13c2da4a43 (diff) | |
Enhance code quality across the entire codebase
Diffstat (limited to 'mingling_core/src/any.rs')
| -rw-r--r-- | mingling_core/src/any.rs | 18 |
1 files changed, 13 insertions, 5 deletions
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<G>` -/// After being passed into AnyOutput, it will be converted to `Box<dyn Any + Send + 'static>` +/// After being passed into `AnyOutput`, it will be converted to `Box<dyn Any + Send + 'static>` /// /// 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<G> { } impl<G> AnyOutput<G> { - /// Create an AnyOutput from a `Send + Groupped<G> + Serialize` type + /// Create an `AnyOutput` from a `Send + Groupped<G> + Serialize` type #[cfg(feature = "general_renderer")] pub fn new<T>(value: T) -> Self where @@ -37,7 +37,7 @@ impl<G> AnyOutput<G> { } } - /// Create an AnyOutput from a `Send + Groupped<G>` type + /// Create an `AnyOutput` from a `Send + Groupped<G>` type #[cfg(not(feature = "general_renderer"))] pub fn new<T>(value: T) -> Self where @@ -50,7 +50,15 @@ impl<G> AnyOutput<G> { } } - /// 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<T: 'static>(self) -> Result<T, Self> { if self.type_id == std::any::TypeId::of::<T>() { Ok(*self.inner.downcast::<T>().unwrap()) @@ -75,7 +83,7 @@ impl<G> AnyOutput<G> { } #[cfg(feature = "general_renderer")] - /// Restore AnyOutput back to the original Serialize type + /// Restore `AnyOutput` back to the original Serialize type pub fn restore<T: Serialize + 'static>(self) -> Option<T> { if self.type_id == std::any::TypeId::of::<T>() { match self.inner.downcast::<T>() { |
