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

Unable to work with &Result<T, E> #279

Open
rongcuid opened this issue Jul 12, 2023 · 0 comments
Open

Unable to work with &Result<T, E> #279

rongcuid opened this issue Jul 12, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@rongcuid
Copy link

It seems like when I get a &Result<T, E>, miette is unable to handle it at all. IntoDiagnostic requires the error to be Send + Sync + 'static, which is not always possible.

This case occurs when I have a Peekable iterator returning a result type:

let some_iter = (...).peekable();
loop {
    let item: Option<&Result<T, E>> = some_iter.peek(); 
    let inner: &Result<T, E> = item.unwrap();
    let t = inner.into_diagnostic()?; // <-- Error about unable to take *inner because into_diagnostic() takes `self`
    let t = inner.as_ref().into_diagnostic()?; // <- Error about `item` not 'static
    //...
}

It forces me to unwrap because the types just don't check.

@zkat zkat added enhancement New feature or request help wanted Extra attention is needed labels Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants