Skip to content

Make FrameCache::get return a reference instead of cloning the cached value#7834

Merged
emilk merged 2 commits intoemilk:mainfrom
KonaeAkira:pr/frame-cache-get-ref
Jan 11, 2026
Merged

Make FrameCache::get return a reference instead of cloning the cached value#7834
emilk merged 2 commits intoemilk:mainfrom
KonaeAkira:pr/frame-cache-get-ref

Conversation

@KonaeAkira
Copy link
Copy Markdown
Contributor

This is a breaking change.

  • Enables using FrameCache in cases where the cached value cannot be cloned.
  • Improves use cases where only a reference to the cached value is needed.
  • If the user needs an owned value, they can clone it themselves.

Adding a get_ref method instead of changing get would avoid the breaking change, but I didn't want to do so because it is kind of expected for get to return &V when querying a collection.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 6, 2026

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

View snapshot changes at kitdiff

@KonaeAkira KonaeAkira marked this pull request as ready for review January 6, 2026 20:07
Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Makes sense

@emilk emilk added the egui label Jan 11, 2026
@emilk emilk merged commit 7fb4627 into emilk:main Jan 11, 2026
25 of 26 checks passed
@KonaeAkira KonaeAkira deleted the pr/frame-cache-get-ref branch January 11, 2026 15:33
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
…ed value (emilk#7834)

This is a breaking change.

- Enables using `FrameCache` in cases where the cached value cannot be
cloned.
- Improves use cases where only a reference to the cached value is
needed.
- If the user needs an owned value, they can clone it themselves.

Adding a `get_ref` method instead of changing `get` would avoid the
breaking change, but I didn't want to do so because it is kind of
expected for `get` to return `&V` when querying a collection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants