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
use core::ops::MulAssign;
use slice_trait::Slice;
use super::SliceVisit;
#[const_trait]
pub trait SliceMulAssign<T>: Slice<Item = T>
{
/// Multiplies `rhs` to each element in the slice.
///
/// # Example
///
/// ```rust
/// use slice_ops::ops::*;
///
/// let mut x = [1, 2, 3, 4, 5, 6, 7, 8];
///
/// x.mul_assign_all(2);
///
/// assert_eq!(x, [2, 4, 6, 8, 10, 12, 14, 16]);
/// ```
fn mul_assign_all<Rhs>(&mut self, rhs: Rhs)
where
T: MulAssign<Rhs>,
Rhs: Copy;
/// Asynchronously multiplies `rhs` to each element in the slice.
///
/// # Example
///
/// ```rust
/// use slice_ops::ops::*;
///
/// # tokio_test::block_on(async {
/// let mut x = [1, 2, 3, 4, 5, 6, 7, 8];
///
/// x.mul_assign_all_async(2).await;
///
/// assert_eq!(x, [2, 4, 6, 8, 10, 12, 14, 16]);
/// # });
/// ```
#[cfg(feature = "alloc")]
async fn mul_assign_all_async<Rhs>(&mut self, rhs: Rhs)
where
T: MulAssign<Rhs>,
Rhs: Copy;
}
impl<T> SliceMulAssign<T> for [T]
{
fn mul_assign_all<Rhs>(&mut self, rhs: Rhs)
where
T: MulAssign<Rhs>,
Rhs: Copy
{
self.visit_mut(|x| *x *= rhs)
}
#[cfg(feature = "alloc")]
async fn mul_assign_all_async<Rhs>(&mut self, rhs: Rhs)
where
T: MulAssign<Rhs>,
Rhs: Copy
{
self.visit_mut_async(async |x| *x *= rhs).await
}
}
#[cfg(test)]
mod test
{
#[test]
fn it_works()
{
}
}