Skip to content

Elide lifetime parameters - #7

Merged
alice-i-cecile merged 1 commit into
bevyengine:mainfrom
chescock:lifetimes
Sep 5, 2026
Merged

Elide lifetime parameters#7
alice-i-cecile merged 1 commit into
bevyengine:mainfrom
chescock:lifetimes

Conversation

@chescock

@chescock chescock commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Objective

Elide lifetime parameters from shortened type names.

type_name includes lifetime parameters as '_, so a Bevy Query will have a ShortName like Query<'_, '_, &C>. Instead, we should elide the lifetimes and render Query<&C>.

Note that type_name did not originally include lifetimes, and they were added in rust-lang/rust#145284, after this library was created. So I believe this will restore the original behavior of ShortName::of::<T>().

Solution

After a < character, skip any number of '_, s. If we're left with <'_>, then elide the angle brackets completely.

Testing

Added unit tests with lifetimes.

@alice-i-cecile
alice-i-cecile merged commit f896e0d into bevyengine:main Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants