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
use crate::;
/*pub trait IntoInplaceBulk: IntoBulk
{
type IntoInplaceBulk: InplaceBulk;
fn into_inplace_bulk(self) -> Self::IntoInplaceBulk;
}
#[cfg(feature = "alloc")]
impl<I> IntoInplaceBulk for I
where
I: IntoBulk
{
type IntoInplaceBulk = <I as private::_IntoInplace>::_IntoInplace;
fn into_inplace_bulk(self) -> Self::IntoInplaceBulk
{
use crate::into_inplace_bulk::private::_IntoInplace;
self._into_inplace()
}
}
#[cfg(not(feature = "alloc"))]
impl<I> IntoInplaceBulk for I
where
I: IntoBulk<IntoBulk: InplaceBulk>
{
type IntoInplaceBulk = <I as private::_IntoInplace>::_IntoInplace;
fn into_inplace_bulk(self) -> Self::IntoInplaceBulk
{
use crate::into_inplace_bulk::private::_IntoInplace;
self._into_inplace()
}
}
mod private
{
use array_trait::same::Same;
use crate::{InplaceBulk, IntoBulk};
pub trait _IntoInplace
{
type _IntoInplace: InplaceBulk;
fn _into_inplace(self) -> Self::_IntoInplace;
}
#[cfg(feature = "alloc")]
impl<I> _IntoInplace for I
where
I: IntoBulk
{
default type _IntoInplace = crate::vec::IntoBulk<I::Item>;
default fn _into_inplace(self) -> Self::_IntoInplace
{
use crate::Bulk;
self.into_bulk()
.collect::<alloc::vec::Vec<_>, _>()
.into_bulk()
.same()
.ok()
.unwrap()
}
}
impl<I> _IntoInplace for I
where
I: IntoBulk<IntoBulk: InplaceBulk>
{
type _IntoInplace = I::IntoBulk;
fn _into_inplace(self) -> Self::_IntoInplace
{
self.into_bulk()
}
}
}
#[cfg(test)]
mod test
{
use crate::*;
#[cfg(feature = "alloc")]
#[test]
fn it_works()
{
let a = [1u8, 2, 3, 4, 5];
let mut b = a.into_bulk()
.map(|x| 6 - x)
.into_inplace_bulk();
b.swap_inplace(1, 3);
let c: [_; 5] = b.collect::<Vec<_>, _>()
.try_into()
.ok()
.unwrap();
assert_eq!(c, [5, 2, 3, 4, 1])
}
}*/