Skip to content

Don't capture self in TableIter<'a, ...>::iter()#294

Open
dubrowgn wants to merge 1 commit intoIndra-db:mainfrom
dubrowgn:pr/table-iter-static
Open

Don't capture self in TableIter<'a, ...>::iter()#294
dubrowgn wants to merge 1 commit intoIndra-db:mainfrom
dubrowgn:pr/table-iter-static

Conversation

@dubrowgn
Copy link
Copy Markdown

@dubrowgn dubrowgn commented May 5, 2026

Due to the changes to capture logic in rust 2024 when returning impl TYPE, the result of TableIter::iter() currently captures an immutable reference to &self. Thus, one cannot mutably use a TableIter while the results of TableIter::iter() are being held.

Use precise capturing on TableIter::iter() to allow the mutable use of TableIter while the result of TableIter::iter() is being held.

See: https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules

Due to the changes to capture logic in rust 2024 when returning
`impl TYPE`, the result of `TableIter::iter()` currently captures an
immutable reference to `&self`. Thus, one cannot mutably use a
`TableIter` while the results of `TableIter::iter()` are being held.

Use precise capturing on `TableIter::iter()` to allow the mutable use of
`TableIter` while the result of `TableIter::iter()` is being held.

See: https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules
@dubrowgn dubrowgn force-pushed the pr/table-iter-static branch from 5ef8386 to b97658a Compare May 5, 2026 18:17
@dubrowgn
Copy link
Copy Markdown
Author

dubrowgn commented May 5, 2026

Initially, this used + 'static instead. While this worked in local testing, it stopped working when I pulled the hotfix in via Cargo.toml. I'm not sure why this is, but use<> seems to work in all cases, so I updated the PR to use that instead.

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.

1 participant