diff options
| author | HampusM <hampus@hampusmat.com> | 2026-09-21 23:49:20 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-09-21 23:49:20 +0200 |
| commit | 6ccfd7833272638953a2b3548f30ec0a6f3149de (patch) | |
| tree | d63f0ef01e851c63c619904d38d51992c5eb4cdd /engine-reflection/src/lib.rs | |
| parent | 7003d9de96824f3e1cb67d56c1c4be883f6e2520 (diff) | |
refactor(engine-reflection): add & fix clippy lints
Diffstat (limited to 'engine-reflection/src/lib.rs')
| -rw-r--r-- | engine-reflection/src/lib.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index dedfee7..23e6b8e 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::all, clippy::pedantic)] use std::alloc::Layout; use std::any::{type_name, Any, TypeId}; use std::borrow::Cow; @@ -14,6 +15,7 @@ pub unsafe trait Reflection: 'static { const TYPE_REFLECTION: &Type; + #[must_use] fn type_reflection() -> &'static Type where Self: Sized, @@ -21,6 +23,7 @@ pub unsafe trait Reflection: 'static Self::TYPE_REFLECTION } + #[must_use] fn get_type_reflection(&self) -> &'static Type { Self::TYPE_REFLECTION @@ -51,6 +54,7 @@ pub enum Type impl Type { + #[must_use] pub const fn as_struct(&self) -> Option<&Struct> { match self { @@ -59,6 +63,7 @@ impl Type } } + #[must_use] pub const fn as_enum(&self) -> Option<&Enum> { match self { @@ -68,6 +73,7 @@ impl Type } #[inline] + #[must_use] pub fn default_value(&self) -> Option<Box<dyn Any>> { match self { @@ -79,6 +85,7 @@ impl Type } #[inline] + #[must_use] pub fn has_default_value(&self) -> bool { match self { @@ -90,6 +97,7 @@ impl Type } #[inline] + #[must_use] pub fn cast_dyn_any(&self, ptr: *mut c_void) -> Option<*mut dyn Any> { match self { @@ -118,12 +126,14 @@ pub struct Struct impl Struct { #[inline] + #[must_use] pub fn default_value(&self) -> Option<Box<dyn Any>> { Some((self.get_default_value)()?()) } #[inline] + #[must_use] pub fn has_default_value(&self) -> bool { (self.get_default_value)().is_some() @@ -148,12 +158,14 @@ pub struct Enum impl Enum { #[inline] + #[must_use] pub fn default_value(&self) -> Option<Box<dyn Any>> { Some((self.get_default_value)()?()) } #[inline] + #[must_use] pub fn has_default_value(&self) -> bool { (self.get_default_value)().is_some() @@ -224,11 +236,11 @@ pub enum EnumVariantFields impl EnumVariantFields { + #[must_use] pub fn fields(&self) -> &'static [EnumVariantField] { match self { - Self::Named { fields } => fields, - Self::Unnamed { fields } => fields, + Self::Named { fields } | Self::Unnamed { fields } => fields, } } } @@ -245,11 +257,13 @@ pub struct EnumVariantField impl EnumVariantField { + #[must_use] pub fn type_name(&self) -> &'static str { self.get_type_name.get() } + #[must_use] pub fn type_reflection(&self) -> Option<&'static Type> { self.get_type.get() @@ -274,11 +288,13 @@ pub struct Field impl Field { + #[must_use] pub fn type_name(&self) -> &'static str { self.get_type_name.get() } + #[must_use] pub fn type_reflection(&self) -> Option<&'static Type> { self.get_type.get() @@ -300,6 +316,7 @@ pub struct Array impl Array { + #[must_use] pub fn item_type_name(&self) -> &'static str { self.get_item_type_name.get() @@ -318,6 +335,7 @@ pub struct Slice impl Slice { + #[must_use] pub fn item_type_name(&self) -> &'static str { self.get_item_type_name.get() @@ -339,12 +357,14 @@ pub struct Literal impl Literal { #[inline] + #[must_use] pub fn default_value(&self) -> Option<Box<dyn Any>> { Some((self.get_default_value)()?()) } #[inline] + #[must_use] pub fn has_default_value(&self) -> bool { (self.get_default_value)().is_some() @@ -625,6 +645,7 @@ impl<Value> FnWithDebug<Value> Self { func } } + #[must_use] pub fn get(&self) -> Value { (self.func)() |
