caches-rs icon indicating copy to clipboard operation
caches-rs copied to clipboard

no_std compatability

Open pantsman0 opened this issue 7 months ago • 7 comments

How do you get the crate to compile in no_std environments?

running cargo check --no-default-features --features hashbrown give the following error importing std:

error[E0433]: failed to resolve: use of undeclared crate or module `std`
 --> src\lfu\tinylfu\bloom.rs:9:19
  |
9 | const LN_2: f64 = std::f64::consts::LN_2;
  |                   ^^^ use of undeclared crate or module `std`
  |
help: consider importing one of these items
  |
7 + use core::f32::consts;
  |
7 + use core::f64::consts;
  |
help: if you import `consts`, refer to it directly
  |
9 - const LN_2: f64 = std::f64::consts::LN_2;
9 + const LN_2: f64 = consts::LN_2;
  |

error[E0599]: no method named `clone` found for struct `CountMinSketch` in the current scope
   --> src\lfu\tinylfu.rs:156:27
    |
156 |             ctr: self.ctr.clone(),
    |                           ^^^^^ method not found in `CountMinSketch`
    |
   ::: src\lfu\tinylfu\sketch\count_min_sketch_core.rs:16:1
    |
16  | pub(crate) struct CountMinSketch {
    | -------------------------------- method `clone` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `clone`, perhaps you need to implement it:
            candidate #1: `Clone`

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `caches` (lib) due to 2 previous errors```

Running without `--features hashbrown` gives even more errors, enough that my terminal cut of the history.
https://gist.github.com/pantsman0/4d9e0178ba6270ef1e1915c39b1e3e75

pantsman0 avatar Dec 02 '23 04:12 pantsman0