pub struct Spanned<T> {
pub value: T,
pub span: Span,
}Expand description
Wraps a value T with its source Span.
Use this as a field type in your Deserialize structs
when you need to preserve span information alongside the deserialized value.
§Examples
use toml_spanner::{Arena, Spanned};
let arena = Arena::new();
let mut table = toml_spanner::parse("name = \"hello\"", &arena)?;
let name: Spanned<String> = table.required("name")?;
assert_eq!(name.value, "hello");
assert!(name.span.start < name.span.end);Fields§
§value: TThe deserialized value.
span: SpanThe byte-offset span in the source document.
Implementations§
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Spanned<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Spanned<T>where
T: Deserialize<'de>,
Source§impl<T> Ord for Spanned<T>where
T: Ord,
impl<T> Ord for Spanned<T>where
T: Ord,
Source§impl<T> PartialOrd for Spanned<T>where
T: PartialOrd,
impl<T> PartialOrd for Spanned<T>where
T: PartialOrd,
impl<T> Eq for Spanned<T>where
T: Eq,
Auto Trait Implementations§
impl<T> Freeze for Spanned<T>where
T: Freeze,
impl<T> RefUnwindSafe for Spanned<T>where
T: RefUnwindSafe,
impl<T> Send for Spanned<T>where
T: Send,
impl<T> Sync for Spanned<T>where
T: Sync,
impl<T> Unpin for Spanned<T>where
T: Unpin,
impl<T> UnsafeUnpin for Spanned<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Spanned<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more