MCPcopy Create free account
hub / github.com/hashintel/hash / update

Method update

libs/@local/hashql/core/src/span/table.rs:243–262  ·  view source on GitHub ↗

Modifies an existing span and its ancestor relationships. Provides mutable access to both the span data and its ancestor configuration. # Returns - `true` if the span was found and successfully modified - `false` if the span doesn't exist or belongs to a different source # Examples Changing resolution mode: ```rust use hashql_core::span::{SpanAncestors, SpanResolutionMode, SpanTable, TextRan

(&mut self, span: SpanId, func: impl FnOnce(&mut S, SpanAncestorsMut))

Source from the content-addressed store, hash-verified

241 /// assert!(!success); // Modification rejected
242 /// ```
243 pub fn update(&mut self, span: SpanId, func: impl FnOnce(&mut S, SpanAncestorsMut)) -> bool {
244 if span.source_id() != self.source_id {
245 return false;
246 }
247
248 let index = span.id().as_usize();
249
250 let Some(element) = self.spans.get_mut(index) else {
251 return false;
252 };
253
254 func(
255 &mut element.span,
256 SpanAncestorsMut {
257 spans: &mut self.ancestors[element.ancestors.clone()],
258 mode: &mut element.mode,
259 },
260 );
261 true
262 }
263
264 fn get_entry(&self, span: SpanId) -> Option<&SpanEntry<S>> {
265 if span.source_id() != self.source_id {

Callers 1

coverMethod · 0.45

Calls 6

funcFunction · 0.85
source_idMethod · 0.80
as_usizeMethod · 0.45
idMethod · 0.45
get_mutMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected