Document how this should work on floats?
Perhaps it's just a part of the language, but if I want to use
#[cached(time=60)]
async fn get_alerts(config: &cmdline::Config) -> Result<Vec<Alert>, reqwest::Error> {
I would expect that to work as is. The problem I'm having is that Config there contains an f64. That f64 doesn't implement Hash. I think I get how to do this, but perhaps more could be done to help the user in this case? It's kind of a pita to have to write all this code to say NaN = NaN.
Yeah, floats not implementing hash is just a pain point of the language. An alternative would be to specify a convert that returns a unique value (that does hash) from your config value:
#[cached(..., convert = r#"{ make_config_key(config) }"#)]
@jaemk what we should if we have float in multiple nested structs as param for cached function?
Request{
i32,
&str,
SomethingElse{
f32
}
}
and we have such function: fn CacheableFunc(req: Request)