Add on_setup_once and on_teardown_once convenience methods#209
Merged
ryanoneill merged 1 commit intomainfrom Mar 9, 2026
Merged
Add on_setup_once and on_teardown_once convenience methods#209ryanoneill merged 1 commit intomainfrom
ryanoneill merged 1 commit intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
==========================================
- Coverage 92.08% 92.08% -0.01%
==========================================
Files 144 144
Lines 12766 12778 +12
==========================================
+ Hits 11756 11767 +11
- Misses 1010 1011 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0839449 to
af3d7e5
Compare
…Config The existing hook API requires `Fn` closures, which forces users into interior mutability patterns when they need to consume captured values. Since hooks run at most once, `FnOnce` is semantically correct. These new methods accept `FnOnce` closures and wrap them internally with a Mutex to maintain compatibility with the `Fn`-based `TerminalHook` type and `RuntimeConfig: Clone`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
af3d7e5 to
e545825
Compare
ryanoneill
added a commit
that referenced
this pull request
Mar 9, 2026
Replace on_setup(Arc::new(|| ...)) with on_setup_once(|| ...) to demonstrate the preferred FnOnce convenience API added in PR #209. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
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.
Summary
on_setup_onceandon_teardown_oncemethods toRuntimeConfigthat acceptFnOnceclosures, eliminating the need forArc<Mutex<Option<...>>>wrappers when hooks consume captured stateFnOnceinternally with aMutexto maintain compatibility with the existingFn-basedTerminalHooktype andRuntimeConfig: CloneTest plan
cargo test --all-features --lib -- config::tests)cargo clippy --all-features -- -D warningsclean🤖 Generated with Claude Code