Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generator: Work around invariance for assigning mutable pointer of li…
…fetimed slice (#841) In essence this builder function needs to adhere to two rules: 1. No ref-after-free: the slice must outlive (uses of) the builder object; 2. No aliasing: the slice cannot be (im)mutably used while it is mutably borrowed within a live builder object. These two rules have been tested and are satisfied by the given builder implementation. Without this change `timings` seems to be borrowing itself, hence is not allowed to be used after it has been temporarily mutably borrowed inside the builder, even after that builder was dropped. Thus defeating the purpose of this "getter" API via a struct. Without the `.cast()`, because mutable raw pointers are invariant (i.e. there is no subtyping relationship) the compiler complains about requiring `self` to outlive `timings` instead, which does not satisfy the two rules above.
- Loading branch information