mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 02:54:11 +08:00

This can be used when you primarily want to return a reference but in order for that reference to live long enough it must be returned with an object. i.e. given `Mutex<Foo { bar }>` you want a function to lock the mutex and return a reference to `bar` but you can't return that reference since it has a lifetime dependency on `MutexGuard` (which only derefs to all of `Foo` and not just `bar`). You can return a `Projection` owning the `MutexGuard<Foo>` and set it up to deref to `&bar`.