turbo
3c68afa1 - Introduce TraitRefs, remove cell_local (#3887)

Commit
2 years ago
Introduce TraitRefs, remove cell_local (#3887) `.cell_local`'s semantics are very confusing and can be the cause of particularly hard-to-debug issues. Furthermore, they can't be nested correctly, which is necessary for my future HMR work. Instead, @sokra proposed that we should always use `ReadRef`s instead. This PR introduces a way to generate `ReadRef`-like `TraitRef`s for a given trait Vc. The purpose of these refs is only to be passed around, to be converted back into a `Vc` eventually. You can't call any other method on a `TraitRef`. This serves the same purpose as `cell_local`, as you can "snapshot" a value pointed to by a trait Vc through a trait ref, and re-cell that snapshot at a later time (see the tests). However, this has the same pitfall as `cell_local`: nested `Vc`s will still update. @sokra proposed we should have `ValueSnapshot` types which flatten nested `Vc`s recursively, but this will have to wait until we have time to tackle tech debt. This also introduces the `ReadRef::cell` method, which works the same way as `TraitRef::cell` but can be used on `ReadRef`s instead.
Author
Parents
Loading