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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use core::ops::{Div, DivAssign};
use slice_trait::Slice;
use super::SliceVisit;
#[const_trait]
pub trait SliceDivAssign<T>: Slice<Item = T>
{
/// Divides each element in the slice by `rhs`.
///
/// # Example
///
/// ```rust
/// use slice_ops::ops::*;
///
/// let mut x = [1, 2, 3, 4, 5, 6, 7, 8];
///
/// x.div_assign_all(2);
///
/// assert_eq!(x, [0, 1, 1, 2, 2, 3, 3, 4]);
/// ```
fn div_assign_all<Rhs>(&mut self, rhs: Rhs)
where
T: DivAssign<Rhs>,
Rhs: Copy;
/// Asynchronously divides each element in the slice by `rhs`.
///
/// # Example
///
/// ```rust
/// use slice_ops::ops::*;
///
/// # tokio_test::block_on(async {
/// let mut x = [1, 2, 3, 4, 5, 6, 7, 8];
///
/// x.div_assign_all_async(2).await;
///
/// assert_eq!(x, [0, 1, 1, 2, 2, 3, 3, 4]);
/// # });
/// ```
#[cfg(feature = "alloc")]
async fn div_assign_all_async<Rhs>(&mut self, rhs: Rhs)
where
T: DivAssign<Rhs>,
Rhs: Copy;
/// TODO
fn rdiv_assign_all<Lhs>(&mut self, lhs: Lhs)
where
Lhs: Copy + Div<T, Output = T>;
/// TODO
#[cfg(feature = "alloc")]
async fn rdiv_assign_all_async<Lhs>(&mut self, lhs: Lhs)
where
Lhs: Copy + Div<T, Output = T>;
}
impl<T> SliceDivAssign<T> for [T]
{
fn div_assign_all<Rhs>(&mut self, rhs: Rhs)
where
T: DivAssign<Rhs>,
Rhs: Copy
{
self.visit_mut(|x| *x /= rhs)
}
#[cfg(feature = "alloc")]
async fn div_assign_all_async<Rhs>(&mut self, rhs: Rhs)
where
T: DivAssign<Rhs>,
Rhs: Copy
{
self.visit_mut_async(async |x| *x /= rhs).await
}
fn rdiv_assign_all<Lhs>(&mut self, lhs: Lhs)
where
Lhs: Copy + Div<T, Output = T>
{
self.visit_mut(|x| unsafe {
core::ptr::write(x, lhs / core::ptr::read(x))
})
}
#[cfg(feature = "alloc")]
async fn rdiv_assign_all_async<Lhs>(&mut self, lhs: Lhs)
where
Lhs: Copy + Div<T, Output = T>
{
self.visit_mut_async(async |x| unsafe {
core::ptr::write(x, lhs / core::ptr::read(x))
}).await
}
}
#[cfg(test)]
mod test
{
#[test]
fn it_works()
{
}
}