Open big-lip-bob opened 3 years ago
i am aware that i could specify the type, (as #[cached] fn add_one_usize(n: usize) -> usize { n + usize::one() }
) (attempting at a macro now)
@big-lip-bob did you ever resolve this?
No, i left it dormant as i didn't have much time since then
I ran into a similar issue and wrote the generic_singleton crate. It doesn't have any of the fancy macros cached
has, mostly because it wasn't really aimed at writing a caching library, but there is no reason it cannot be done. Or perhaps even better, cached
can use the generic_singleton
crate to add the generic function caching feature :)
Since apparently i can't really use cached with generic functions (let's say
fn add_one<T: One + Add<Output=T>>(n: T) -> T { n + T::one() }
), how would i proceed to make a cache for a specific type that's valid as said generic (let's useusize
) ?