From 7e8d7dd8d81ba9bb1c72a735c8b6176b16947e81 Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Fri, 3 Jan 2025 04:45:26 +0100 Subject: [PATCH] feat(sentry-tower) Make SentryLayer and SentryService `Sync` if request isn't --- sentry-tower/src/lib.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sentry-tower/src/lib.rs b/sentry-tower/src/lib.rs index 4cd9818d..cccf2e8f 100644 --- a/sentry-tower/src/lib.rs +++ b/sentry-tower/src/lib.rs @@ -196,7 +196,7 @@ where H: Into>, { provider: P, - _hub: PhantomData<(H, Request)>, + _hub: PhantomData<(H, fn() -> Request)>, } impl Layer for SentryLayer @@ -250,7 +250,7 @@ where { service: S, provider: P, - _hub: PhantomData<(H, Request)>, + _hub: PhantomData<(H, fn() -> Request)>, } impl Service for SentryService @@ -326,3 +326,21 @@ impl NewSentryService { } } } + +#[cfg(test)] +mod tests { + use super::*; + use std::rc::Rc; + + fn assert_sync() {} + + #[test] + fn test_layer_is_sync_when_request_isnt() { + assert_sync::>>(); // Rc<()> is not Sync + } + + #[test] + fn test_service_is_sync_when_request_isnt() { + assert_sync::>>(); // Rc<()> is not Sync + } +}