pub struct Anchored<T, G>{ /* private fields */ }Expand description
A value computed against a specific edit generation.
An offset is a claim about text. When the text changes the claim expires,
and the expiry is invisible: the number is still a number, and it still
indexes something. SearchState::refresh existed to prevent exactly this
and had zero callers for as long as it existed, which is the argument for
making staleness a type rather than a discipline.
Anchored::get takes the CURRENT generation and returns None when they
disagree, so a stale read is a visible absence instead of a wrong column.
Implementations§
Source§impl<T, G> Anchored<T, G>
impl<T, G> Anchored<T, G>
pub const fn new(value: T, at: G) -> Anchored<T, G>
Sourcepub const fn generation(&self) -> G
pub const fn generation(&self) -> G
The generation this was computed against.
Sourcepub const fn get_possibly_stale(&self) -> &T
pub const fn get_possibly_stale(&self) -> &T
Read the value regardless of freshness.
Named to be conspicuous at the call site: reaching for it is a claim that staleness does not matter here, and that claim should be visible in review rather than hidden behind a plain accessor.