Fix lifetime invariance in FrameIterator and WindowIterator#1
Draft
Fix lifetime invariance in FrameIterator and WindowIterator#1
Conversation
Agent-Logs-Url: https://github.com/jmg049/audio_samples/sessions/e9da144d-1527-4ea1-80de-73aa82b27a81 Co-authored-by: jmg049 <121042936+jmg049@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate audio samples iterators and lifetime associations
Fix lifetime invariance in FrameIterator and WindowIterator
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AudioSamples<'a, T>is invariant in'a, so using a single lifetime for both the reference-to-AudioSamples and its internal data lifetime made.frames()and.windows()unusable from any function taking&AudioSamples<T>— the compiler required the caller to explicitly write&'a AudioSamples<'a, T>with unified lifetimes.Changes
FrameIterator<'a, T>→FrameIterator<'s, 'a, T>— separates the reference lifetime'sfrom the data lifetime'a, with an'a: 'sbound. Matches the patternChannelIteratoralready used correctly.WindowIterator<'a, T>→WindowIterator<'s, 'a, T>— same treatment.AudioSamples::frames()/::windows()— changed from&'a selfto&'s self, decoupling the borrow lifetime from the data lifetime.AudioSampleIteratorstrait — updatedframesandwindowssignatures to match.next()implementations — explicitly copies the stored&'sreference before callingslice_samplesto preserve the full'slifetime through the method call.test_frames_on_borrow,test_channels_on_borrow,test_windows_on_borrow, andtest_frames_and_windows_same_borrowed_refto guard against recurrence.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
googlechromelabs.github.io/tmp/codeql-scratch-36880336822b49dd/dbs/rust/working/target/debug/build/plotly_static-311d80930e9c4e8d/build-script-build /tmp/codeql-scratch-36880336822b49dd/dbs/rust/working/target/debug/build/plotly_static-311d80930e9c4e8d/build-script-build --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 menter_data-855c8a22ae92df5b/rustchALHME/symbols.o menter_data-855c8a22ae92df5b/build_script_build-855c8a22ae92df5b.build_script_build.bfce194cf466c7c3-cgu.0.rcgu.o menter_data-855c8a22ae92df5b/build_script_build-855c8a22ae92df5b.d6sf3ohay0ur3mrj9cveizfax.rcgu.o -fuse-ld=lld -z 64-REDACTED-linux-gnu/lib/libstd-46d936097e8c5b85.rlib 64-REDACTED-linux-gnu/lib/libpanic_unwind-e462f106b2b26a06.rlib 64-REDACTED-linux-gnu/lib/libobject-926daa94a00ee327.rlib 64-REDACTED-linux-gnu/lib/libmemchr-48d5b0db80402653.rlib 64-REDACTED-linux-gnu/lib/libaddr2line-3367f26bd486b29d.rlib 64-REDACTED-linux-gnu/lib/libgimli-7aeefe72516b1ebd.rlib 64-REDACTED-linux-gnu/lib/libcfg_if-a5addfdc94c3bad3.rlib 64-REDACTED-linux-gnu/lib/librustc_demangle-789fb9c0cb1c7158.rlib 64-REDACTED-linux-gnu/lib/libstd_detect-b16e5cb5eba3e0fd.rlib 64-REDACTED-linux-gnu/lib/libhashbrown-70305b2ec0766fa6.rlib(dns block)If you need me to access, download, or install something from one of these locations, you can either: