argmin/core/
parallelization.rs

1// Copyright 2018-2024 argmin developers
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8/// Trait alias for `Send`
9///
10/// If the `rayon` feature is set, it acts as an alias for `Send` and is implemented for all
11/// types which implement `Send`. If `rayon` is not set, it will be an "empty" trait
12/// implemented for all types.
13#[cfg(feature = "rayon")]
14pub trait SendAlias: Send {}
15
16/// Trait alias for `Send`
17///
18/// If the `rayon` feature is set, it acts as an alias for `Send` and is implemented for all
19/// types which implement `Send`. If `rayon` is not set, it will be an "empty" trait
20/// implemented for all types.
21#[cfg(not(feature = "rayon"))]
22pub trait SendAlias {}
23
24#[cfg(feature = "rayon")]
25impl<T> SendAlias for T where T: Send {}
26
27#[cfg(not(feature = "rayon"))]
28impl<T> SendAlias for T {}
29
30/// Trait alias for `Sync`
31///
32/// If the `rayon` feature is set, it acts as an alias for `Sync` and is implemented for all types
33/// which implement `Sync`. If `rayon` is not set, it will be an "empty" trait implemented for all
34/// types.
35#[cfg(feature = "rayon")]
36pub trait SyncAlias: Sync {}
37
38/// Trait alias for `Sync`
39///
40/// If the `rayon` feature is set, it acts as an alias for `Sync` and is implemented for all types
41/// which implement `Sync`. If `rayon` is not set, it will be an "empty" trait implemented for all
42/// types.
43#[cfg(not(feature = "rayon"))]
44pub trait SyncAlias {}
45
46#[cfg(feature = "rayon")]
47impl<T> SyncAlias for T where T: Sync {}
48
49#[cfg(not(feature = "rayon"))]
50impl<T> SyncAlias for T {}