1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use core::ops::Not;
use slice_trait::Slice;
use super::SliceVisit;
#[const_trait]
pub trait SliceNotAssign<T>: Slice<Item = T>
{
/// Performs a logical NOT or bitwise NOT on each element in the slice.
///
/// Booleans will be treated with a logical NOT, while integers will be treated with a bitwise NOT.
///
/// # Example
///
/// ```rust
/// use slice_ops::ops::*;
///
/// let mut x = [true, false, true, false, true, false, true, true];
///
/// x.not_assign_all();
///
/// assert_eq!(x, [false, true, false, true, false, true, false, false]);
/// ```
fn not_assign_all(&mut self)
where
T: Not<Output = T>;
/// Asynchronously performs a logical NOT or bitwise NOT on each element in the slice.
///
/// Booleans will be treated with a logical NOT, while integers will be treated with a bitwise NOT.
///
/// # Example
///
/// ```rust
/// use slice_ops::ops::*;
///
/// # tokio_test::block_on(async {
/// let mut x = [true, false, true, false, true, false, true, true];
///
/// x.not_assign_all_async().await;
///
/// assert_eq!(x, [false, true, false, true, false, true, false, false]);
/// # });
/// ```
#[cfg(feature = "alloc")]
async fn not_assign_all_async(&mut self)
where
T: Not<Output = T>;
}
impl<T> SliceNotAssign<T> for [T]
{
fn not_assign_all(&mut self)
where
T: Not<Output = T>
{
self.visit_mut(|x| unsafe {
core::ptr::write(x, !core::ptr::read(x))
})
}
#[cfg(feature = "alloc")]
async fn not_assign_all_async(&mut self)
where
T: Not<Output = T>
{
self.visit_mut_async(async |x| unsafe {
core::ptr::write(x, !core::ptr::read(x))
}).await
}
}
#[cfg(test)]
mod test
{
#[test]
fn it_works()
{
}
}