From d7ddbb73da487ba5dbc5d3c64eb764a9eb50b554 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 26 Jan 2025 09:00:24 +0100 Subject: [PATCH] refactor * make `Send` docs more prominent * add test --- gix/src/types.rs | 10 +++++++--- gix/tests/gix/repository/mod.rs | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gix/src/types.rs b/gix/src/types.rs index 6e43a07f90b..4ada3d5c72d 100644 --- a/gix/src/types.rs +++ b/gix/src/types.rs @@ -150,7 +150,9 @@ pub struct Reference<'r> { /// and explicitly. This is to have the fastest-possible default configuration available by default, but allow /// those who experiment with workloads to get speed boosts of 2x or more. /// -/// Note: when built with `default-features = false`, this type is **not** `Send`. +/// ### `Send` only with `parallel` feature +/// +/// When built with `default-features = false`, this type is **not** `Send`. /// The minimal feature set to activate `Send` is `features = ["parallel"]`. pub struct Repository { /// A ref store with shared ownership (or the equivalent of it). @@ -186,8 +188,10 @@ pub struct Repository { /// /// Note that it can also cheaply be cloned, and it will retain references to all contained resources. /// -/// Note: when built with `default-features = false`, this type is **not** `Send` or `Sync`. -/// The minimal feature set to activate `Send + Sync` is `features = ["parallel"]`. +/// ### `Send` only with `parallel` feature +/// +/// When built with `default-features = false`, this type is **not** `Send`. +/// The minimal feature set to activate `Send` is `features = ["parallel"]`. #[derive(Clone)] pub struct ThreadSafeRepository { /// A store for references to point at objects diff --git a/gix/tests/gix/repository/mod.rs b/gix/tests/gix/repository/mod.rs index 2909186ba6a..7a0c05fde67 100644 --- a/gix/tests/gix/repository/mod.rs +++ b/gix/tests/gix/repository/mod.rs @@ -138,3 +138,11 @@ fn thread_safe_repository_is_sync() -> crate::Result { f(crate::util::basic_repo()?.into_sync()); Ok(()) } + +#[test] +#[cfg(feature = "parallel")] +fn repository_is_send() -> crate::Result { + fn f(_t: T) {} + f(crate::util::basic_repo()?); + Ok(()) +}