mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-10-13 23:32:42 +00:00
`VersatileBuffer<A>` (tantivy-common) keeps an allocation and lends it as an empty `Vec<T>`, for any `T` with the size and alignment of `A`. The allocation goes back to the buffer when the guard is dropped, including on panic. If the guard is leaked, the buffer starts again from an empty `Vec`. This makes it possible to reuse a buffer of values borrowing data with a short lifetime, without self-referential structs. The jitexpr predicate uses it for its argument slots. It replaces the `ClearOnDrop` guard, which transmuted a `Vec<VariableValue<'static>>` to a shorter lifetime. Co-authored-by: Paul Masurel <paul.masurel@datadoghq.com>