Skip to content

Commit ffd8187

Browse files
committed
Make impl_delegating_deserialize! easier to use
No longer requires explicit <'gc, 'de, Id> if the type has no generic params.
1 parent 65945e7 commit ffd8187

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/serde.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ impl<'gc, 'de, Id: CollectorId, T: GcDeserialize<'gc, 'de, Id>> GcDeserialize<'g
4040
/// This should only be used for types that can never have gc pointers inside of them (or if you don't care to support that).
4141
#[macro_export]
4242
macro_rules! impl_delegating_deserialize {
43+
(impl GcDeserialize for $target:path) => (
44+
impl_delegating_deserialize!(impl <'gc, 'de, Id> GcDeserialize<'gc, 'de, Id> for $target where Id: zerogc::CollectorId);
45+
);
4346
(impl $(<$($lt:lifetime,)* $($param:ident),*>)? GcDeserialize<$gc:lifetime, $de:lifetime, $id:ident> for $target:path $(where $($where_clause:tt)*)?) => {
4447
impl$(<$($lt,)* $($param),*>)? $crate::serde::GcDeserialize<$gc, $de, $id> for $target
4548
where Self: Deserialize<'deserialize> + $(, $($where_clause)*)?{
46-
fn deserialize_gc(_ctx: <Id::System as GcSystem>::Context, deserializer: D) -> Result<Self, D::Error> {
49+
fn deserialize_gc<D: serde::Deserializer<$de>>(_ctx: <Id::System as GcSystem>::Context, deserializer: D) -> Result<Self, <D as serde::Deserializer<$de>>::Error> {
4750
<Self as serde::Deserialize<'deserialize>>::deserialize(deserializer)
4851
}
4952
}

0 commit comments

Comments
 (0)