Skip to content

Commit

Permalink
Change NonZero* TypeInfo implementation to not be recursive (#171)
Browse files Browse the repository at this point in the history
* Change NonZero* TypeInfo not recursive

* Fix test
  • Loading branch information
benluelo committed Nov 15, 2022
1 parent ad90cb1 commit 6d9cb83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,31 @@ impl_metadata_for_tuple!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S
impl_metadata_for_tuple!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T);

macro_rules! impl_for_non_zero {
( $( $t: ty ),* $(,)? ) => {
( $( $t: ty: $inner: ty ),* $(,)? ) => {
$(
impl TypeInfo for $t {
type Identity = Self;
fn type_info() -> Type {
Type::builder()
.path(Path::prelude(stringify!($t)))
.composite(Fields::unnamed().field(|f| f.ty::<$t>()))
.composite(Fields::unnamed().field(|f| f.ty::<$inner>()))
}
}
)*
};
}

impl_for_non_zero!(
NonZeroI8,
NonZeroI16,
NonZeroI32,
NonZeroI64,
NonZeroI128,
NonZeroU8,
NonZeroU16,
NonZeroU32,
NonZeroU64,
NonZeroU128
NonZeroI8: i8,
NonZeroI16: i16,
NonZeroI32: i32,
NonZeroI64: i64,
NonZeroI128: i128,
NonZeroU8: u8,
NonZeroU16: u16,
NonZeroU32: u32,
NonZeroU64: u64,
NonZeroU128: u128
);

impl<T> TypeInfo for Vec<T>
Expand Down
2 changes: 1 addition & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn prelude_items() {
NonZeroU32,
Type::builder()
.path(Path::prelude("NonZeroU32"))
.composite(Fields::unnamed().field(|f| f.ty::<NonZeroU32>()))
.composite(Fields::unnamed().field(|f| f.ty::<u32>()))
)
}

Expand Down

0 comments on commit 6d9cb83

Please sign in to comment.