Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds value-wrapper for borrowed or owned return values #177

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Aug 3, 2023

  1. reverts use of NonZeroUsize for LRU capacity instead of usize

    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.
    behzadnouri committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    4fa447d View commit details
    Browse the repository at this point in the history
  2. adds value-wrapper for borrowed or owned return values

    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 committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    bfc7a80 View commit details
    Browse the repository at this point in the history