Skip to content

CacheRef<'a, T, ...> does not expose &'a T #3464

@tingerrr

Description

@tingerrr

Currently, CacheRef only implements Deref which cannot expose the reference with the 'a lifetime.
Is the lack of a method or inherent function which lets you retrieve this by design, or is this an oversight? If it is by design, it should probably be documented. My guess is that this ref keeps the entry in the cache alive, so referencing it is only safe while the CacheRef exists, is this about correct?

For context: I was migrating a bot which had a util function for either getting a message from the cache or downloading it if necessary, this function returned an owned object because both the cache and download method did. Since the cache no longer serves owned objects, my first instinct was to go for Cow, but this won't work because the lifetime is shortened to that of the CacheRef.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions