Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Fix DefaultExpected::into_owned lifetime - #952

Merged
zesterer merged 1 commit into
zesterer:mainfrom
Zollerboy1:main
Feb 5, 2026
Merged

zesterer merged 1 commit into
zesterer:mainfrom
Zollerboy1:main

Conversation

@Zollerboy1

Copy link
Copy Markdown
Contributor

This PR changes the lifetime returned from DefaultExpected::into_owned to be generic.

This follows the pattern of other into_owned methods in the crate, like RichPattern::into_owned or RichReason::into_owned.

The current implementation has a fixed 'static lifetime return, which doesn't work for me because I have tokens with a non-static lifetime.
My current workaround is to reimplement into_owned, which is awkward because of DefaultExpected's #[non_exhaustive]-ness:

match e {
    DefaultExpected::Token(t) => DefaultExpected::Token(t.into_owned()),
    DefaultExpected::Any => DefaultExpected::Any,
    DefaultExpected::SomethingElse => DefaultExpected::SomethingElse,
    DefaultExpected::EndOfInput => DefaultExpected::EndOfInput,
    _ => panic!("Unexpected expected kind"),
}

@zesterer

zesterer commented Feb 5, 2026

Copy link
Copy Markdown
Owner

Thanks, nice catch!

@zesterer
zesterer merged commit 639f586 into zesterer:main Feb 5, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants