Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty accessing Span from Lazy* types. #810

Open
jpschorr opened this issue Aug 12, 2024 · 0 comments
Open

Difficulty accessing Span from Lazy* types. #810

jpschorr opened this issue Aug 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jpschorr
Copy link
Contributor

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.

@jpschorr jpschorr added the enhancement New feature or request label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant