Open haydnv opened 11 months ago
use memoize::memoize;
#[derive(Clone)]
struct Struct {}
#[derive(Clone)]
struct Error {}
#[memoize(SharedCache, Capacity: 1024)]
fn my_function(arg: &'static str) -> Result<Struct, Error> {
println!("{}", arg);
Ok(Struct{})
}
fn main() {
let s = "Hello World";
my_function(s).ok();
}
I tried this, and it works:
$ cargo run --example issue30
Compiling memoize v0.4.1 (/home/lbo/dev/rust/memoize)
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/examples/issue30`
Hello World
I notice that the symbol which can't be found is upper-cased, but I think current versions use a lower-case version. Can you double check the versions maybe? Otherwise I don't know much right now
I'm definitely using memoize version 0.4.1 with rustc version 1.74.0. Here's the version tree for memoize in case it's helpful:
memoize v0.4.1
│ ├── lazy_static v1.4.0
│ ├── lru v0.7.8
│ │ └── hashbrown v0.12.3
│ │ └── ahash v0.7.7
│ │ ├── getrandom v0.2.11
│ │ │ ├── cfg-if v1.0.0
│ │ │ └── libc v0.2.150
│ │ └── once_cell v1.18.0
│ │ [build-dependencies]
│ │ └── version_check v0.9.4
│ └── memoize-inner v0.4.0 (proc-macro)
│ ├── lazy_static v1.4.0
│ ├── proc-macro2 v1.0.70
│ │ └── unicode-ident v1.0.12
│ ├── quote v1.0.33
│ │ └── proc-macro2 v1.0.70 (*)
│ └── syn v1.0.109
│ ├── proc-macro2 v1.0.70 (*)
│ ├── quote v1.0.33 (*)
│ └── unicode-ident v1.0.12
I'm reporting the same issue on a new project with only memoize and the sample code provided above, both with nightly 1.76.0 and stable 1.74.0.
Here's my version tree:
memoizetest v0.1.0
└── memoize v0.4.1
├── lazy_static v1.4.0
├── lru v0.7.8
│ └── hashbrown v0.12.3
│ └── ahash v0.7.7
│ ├── getrandom v0.2.11
│ │ └── cfg-if v1.0.0
│ └── once_cell v1.19.0
│ [build-dependencies]
│ └── version_check v0.9.4
└── memoize-inner v0.4.0 (proc-macro)
├── lazy_static v1.4.0
├── proc-macro2 v1.0.70
│ └── unicode-ident v1.0.12
├── quote v1.0.33
│ └── proc-macro2 v1.0.70 (*)
└── syn v1.0.109
├── proc-macro2 v1.0.70 (*)
├── quote v1.0.33 (*)
└── unicode-ident v1.0.12
Same issue here, turning on SharedCache
results in a compile error. Here's my code in case more test cases are needed (spoilers for this year's Advent of Code day 12, if anyone is participating):
I also ran into this issue while trying to solve Advent of Code Day 12. I tried building with stable 1.74.0 and 1.74.1, and nightly 1.76.
Here's my code, although fair warning it's a bit of a mess.
EDIT: Pulling the crate from the github repo fixed the problem :)
cargo add --git https://github.com/dermesser/memoize memoize --features full
Hi @dermesser, thank you for this super useful crate! I'm trying to use the
SharedCache
option like so:But when I try to compile this I get:
This is on version 0.4.1. Do you have any ideas about what might be going on?