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))
| 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 { |