Mercurial > lbo > hg > memoize
changeset 22:c15379dd7de7
Improve README explanations.
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 16 Oct 2020 10:12:43 +0200 |
parents | 48a447de2a0f |
children | 3eb3f212b75d |
files | README.md |
diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/README.md Thu Oct 15 23:42:11 2020 +0200 +++ b/README.md Fri Oct 16 10:12:43 2020 +0200 @@ -51,6 +51,32 @@ } ``` +## Further Functionality + +You can choose to use an [LRU cache](https://crates.io/crates/lru). In fact, if +you know that a memoized function has an unbounded number of different inputs, +you should do this! In that case, use the attribute like this: + +```rust +// From examples/test1.rs +// Compile with --features=full +use memoize::memoize; + +#[derive(Debug, Clone)] +struct ComplexStruct { + // ... +} + +#[memoize(Capacity: 123)] +fn hello(key: String) -> ComplexStruct { + // ... +} +``` + +Adding more caches and configuration options is relatively simple, and a matter +of parsing attribute parameters. Currently, compiling will fail if you use a +parameter such as `Capacity` without the feature `full` being enabled. + ## Contributions ...are always welcome! This being my first procedural-macros crate, I am