Skip to content

Ref Wrapper API #6

@ibraheemdev

Description

@ibraheemdev

It is sometimes useful to wrap a Guard and a &V into a single type instead of requiring a Guard as input. We could add a Ref wrapper type to support this. See the advanced lifetimes guide for context.

I'm unsure how the API should look as I don't want this to be the default return type for get. We could potentially add a Ref::create method that takes a guard and a closure that creates a value tied to the guard and extends the lifetime. However, we have to be careful about not creating self references. Though this is unlikely, it would be possible to create a HashMap<K, &Guard> or similar through Ref::create, so we might have to unfortunately restrict it to 'static types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions