diff --git a/src/protocol.rs b/src/protocol.rs index bb6039d..9185de7 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -289,6 +289,11 @@ impl LabeledSpan { self.label = label; } + /// Change the offset of the span + pub fn set_span_offset(&mut self, offset: usize) { + self.span.offset = SourceOffset(offset); + } + /// Makes a new label at specified span /// /// # Examples @@ -370,6 +375,15 @@ impl LabeledSpan { } } +#[test] +fn test_set_span_offset() { + let mut span = LabeledSpan::new(None, 10, 10); + assert_eq!(span.offset(), 10); + + span.set_span_offset(20); + assert_eq!(span.offset(), 20); +} + #[cfg(feature = "serde")] #[test] fn test_serialize_labeled_span() {