diff options
author | HampusM <hampus@hampusmat.com> | 2023-04-01 15:00:06 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-04-01 15:03:29 +0200 |
commit | ba865b581fbc1d0589b402b028f2bce70332891b (patch) | |
tree | 752e7be1150b8a5412b4351803edc6970916d9fa /macros/src/expectation.rs | |
parent | 1628732d6514670fe2108e5063e9d5ba7166ad94 (diff) |
feat: allow for usage of associated types of generics
Diffstat (limited to 'macros/src/expectation.rs')
-rw-r--r-- | macros/src/expectation.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/macros/src/expectation.rs b/macros/src/expectation.rs index 8120cfd..2e86db0 100644 --- a/macros/src/expectation.rs +++ b/macros/src/expectation.rs @@ -180,7 +180,6 @@ impl Expectation ident: Ident, generics: Generics, phantom_fields: &[PhantomField], - returning_fn: &Type, boxed_predicate_types: &[Type], ) -> ItemStruct { @@ -208,7 +207,9 @@ impl Expectation format_ident!("Option"), Some(AngleBracketedGenericArguments::new( WithColons::No, - [GenericArgument::Type(returning_fn.clone())], + [GenericArgument::Type(Type::BareFn( + TypeBareFn::new([], ReturnType::Default), + ))], )), )], ))), @@ -345,7 +346,6 @@ impl ToTokens for Expectation self.ident.clone(), generics.clone(), phantom_fields, - &returning_fn, &boxed_predicate_types, ); @@ -445,7 +445,7 @@ impl ToTokens for Expectation func: #returning_fn ) -> &mut Self { - self.returning = Some(func); + self.returning = Some(unsafe { std::mem::transmute(func) }); self } @@ -536,7 +536,9 @@ impl ToTokens for Expectation self.call_cnt.fetch_add(1, std::sync::atomic::Ordering::Relaxed); - returning + let returning_ptr: *const _ = returning; + + unsafe { &*returning_ptr.cast()} } } |