ion-rust
ion-rust copied to clipboard
Difficulty accessing `Span` from `Lazy*` types.
Using
ion-rs = { version = "1.0.0-rc.6", features = ["experimental"] }
It's somewhat difficult (and sometimes not possible unless I'm missing something) to access the Span for a given Lazy*
Here's what I'm trying:
pub(crate) trait IonSpan<'a> {
fn get_span(&self) -> Option<Span<'a>>;
}
impl<'a> IonSpan<'a> for LazyValue<'a, AnyEncoding> {
fn get_span(&self) -> Option<Span<'a>> {
Some(self.raw()?.span())
}
}
impl<'a> IonSpan<'a> for LazyStruct<'a, AnyEncoding> {
fn get_span(&self) -> Option<Span<'a>> {
self.as_value().get_span()
}
}
impl<'a> IonSpan<'a> for LazyList<'a, AnyEncoding> {
fn get_span(&self) -> Option<Span<'a>> {
todo!("ion-rs doesn't seem to support span or as_value for LazyList")
}
}
impl<'a> IonSpan<'a> for LazyField<'a, AnyEncoding> {
fn get_span(&self) -> Option<Span<'a>> {
todo!("ion-rs doesn't seem to support span or as_value for LazyList")
}
}
impl<'a> IonSpan<'a> for ValueRef<'a, AnyEncoding> {
fn get_span(&self) -> Option<Span<'a>> {
todo!("ion-rs doesn't seem to support span or as_value for LazyList")
}
}
I'm not sure if the implemented methods are ideal, and for several (see the todos), I could find no way to get to the span.