Skip to content

Commit eaf15ba

Browse files
max-sixtyclaude
andauthored
Remove unnecessary Send + Sync bounds from Redaction (#874)
## Summary Follow-up to #873 ("Don't use `Arc` in `Settings` unnecessarily"). - Remove `Send + Sync` bounds from `Redaction::Dynamic` variant - Remove `Send + Sync` bounds from `dynamic_redaction()` function - Remove `Send + Sync` bounds from `Settings::add_dynamic_redaction()` method Since `Settings` are stored in thread-local storage and wrapped in `Rc`, they can never cross thread boundaries. The `Send + Sync` bounds were vestigial from when `Arc` was used for `DEFAULT_SETTINGS`. This relaxes the API to allow non-`Send` closures in dynamic redactions, which is now safe since those closures can never be sent to another thread. ## Test plan - [x] All tests pass with `cargo test --all-features` - [x] No clippy warnings 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent f680868 commit eaf15ba

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ WORKSPACE.bazel
1212
bazel-*
1313

1414
# Emacs backups
15-
*~
15+
*~

insta/src/redaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub enum Redaction {
5454
/// Static redaction with new content.
5555
Static(Content),
5656
/// Redaction with new content.
57-
Dynamic(Box<dyn Fn(Content, ContentPath<'_>) -> Content + Sync + Send>),
57+
Dynamic(Box<dyn Fn(Content, ContentPath<'_>) -> Content>),
5858
}
5959

6060
macro_rules! impl_from {
@@ -127,7 +127,7 @@ impl<'a> From<&'a [u8]> for Redaction {
127127
pub fn dynamic_redaction<I, F>(func: F) -> Redaction
128128
where
129129
I: Into<Content>,
130-
F: Fn(Content, ContentPath<'_>) -> I + Send + Sync + 'static,
130+
F: Fn(Content, ContentPath<'_>) -> I + 'static,
131131
{
132132
Redaction::Dynamic(Box::new(move |c, p| func(c, p).into()))
133133
}

insta/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl Settings {
413413
pub fn add_dynamic_redaction<I, F>(&mut self, selector: &str, func: F)
414414
where
415415
I: Into<Content>,
416-
F: Fn(Content, ContentPath<'_>) -> I + Send + Sync + 'static,
416+
F: Fn(Content, ContentPath<'_>) -> I + 'static,
417417
{
418418
self.add_redaction(selector, dynamic_redaction(func));
419419
}

0 commit comments

Comments
 (0)