Skip to content

Minor atoms improvements #7145

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

Merged
merged 3 commits into from
Jun 16, 2025
Merged

Minor atoms improvements #7145

merged 3 commits into from
Jun 16, 2025

Conversation

lucasmerlin
Copy link
Collaborator

@lucasmerlin lucasmerlin commented Jun 14, 2025

Improve some lifetime bounds and add some convenience constructors

Copy link

Preview available at https://egui-pr-preview.github.io/pr/7145-lucasatoms-improvements
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@@ -82,7 +82,7 @@ impl<'a> Atoms<'a> {
})
}

pub fn iter_texts(&'a self) -> impl Iterator<Item = &'a WidgetText> {
pub fn iter_texts(&self) -> impl Iterator<Item = &WidgetText> + use<'_, 'a> {
Copy link
Collaborator Author

@lucasmerlin lucasmerlin Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These use bounds were new to me but it makes perfect sense.
The concrete return type would be something like FilterMap<Iter<Item=AtomKind<'a> ...> but since WidgetText doesn't have a lifetime this information gets lost. With use we specify the actual lifetime requirements and it compiles.

@lucasmerlin lucasmerlin added feature New feature or request egui labels Jun 14, 2025
@lucasmerlin lucasmerlin merged commit 5194c0d into main Jun 16, 2025
49 checks passed
@lucasmerlin lucasmerlin deleted the lucas/atoms-improvements branch June 16, 2025 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants