Skip to content

Conversation

@behzadnouri
Copy link

- This is on top of:
- https://github.com/jeromefroe/lru-rs/pull/176
- Only the last commit is new code.
- I will rebase once #176 is merged.

get_or_insert, get_or_insert_mut and try_get_or_insert may return None only in the case where capacity is zero.
Instead this commit adds a ValueWrapper:

enum ValueWrapper<'a, V> {
    Borrowed(&'a V),
    Owned(V),
}

which makes it possible for these methods to always return a value which can be borrowed as V.

NonZeroUsize for capacity is very nonergonomic and prevents some
use-cases. For example a usize allows to disable caching by using
capacity zero. see: jeromefroe#165

This reverts commit 0e415ef.
get_or_insert, get_or_insert_mut and try_get_or_insert may return None
only in the case where capacity is zero.
Instead this commit adds a ValueWrapper:

    enum ValueWrapper<'a, V> {
        Borrowed(&'a V),
        Owned(V),
    }

which makes it possible for these methods to always return a value which
can be borrowed as V.
@behzadnouri
Copy link
Author

@jeromefroe This will address the discussion here: #165 (comment)

cc @Yosi-Hezi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant