jaemk / cached

Rust cache structures and easy function memoization
MIT License
1.57k stars 95 forks source link

Cannot call *_no_cache function #168

Closed jqnatividad closed 1 year ago

jqnatividad commented 1 year ago

With the 0.45 release, I was attempting to use the new *_no_cache function and I'm getting a compilation error:

   Compiling qsv v0.112.0 (/Users/joelnatividad/Local/GitHub/qsv)
error[E0425]: cannot find function `search_cached_no_cache` in this scope
   --> src/cmd/geocode.rs:794:25
    |
794 |                           search_cached_no_cache(
    |                           ^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `search_cached_prime_cache`
...
898 | / #[cached(
899 | |     type = "SizedCache<String, String>",
900 | |     create = "{ SizedCache::try_with_size(CACHE_SIZE).unwrap_or_else(|_| \
901 | |               SizedCache::with_size(FALLBACK_CACHE_SIZE)) }",
...   |
904 | |     option = true,
905 | | )]
    | |__- similarly named function `search_cached_prime_cache` defined here

The name of the cached function is search_cached, with the following cache definition:

[cached(
    type = "SizedCache<String, String>",
    create = "{ SizedCache::try_with_size(CACHE_SIZE).unwrap_or_else(|_| \
              SizedCache::with_size(FALLBACK_CACHE_SIZE)) }",
    key = "String",
    convert = r#"{ format!("{cell}") }"#,
    option = true,
)]
fn search_cached(
    engine: &Engine,
    mode: GeocodeSubCmd,
    cell: &str,
    formatstr: &str,
    min_score: Option<f32>,
    k: Option<f32>,
    country_filter_list: &Option<Vec<String>>,
    admin1_filter_list: &Option<Vec<Admin1Filter>>,
    column_values: &Vec<&str>,
) -> Option<String> {

and just for the heck of it, I tried calling search_cached_prime_cache just to see if it compiles and it does.

Thanks in advance!

jaemk commented 1 year ago

Ah, darn. The change was in the proc macro and I forgot to release a new version of that. I'll release the fix tonight

jaemk commented 1 year ago

Alright, out in 0.45.1 and I confirmed it works this time. Sorry about that!

jqnatividad commented 1 year ago

Awesome! Can confirm that it works for me too!