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
/// Splits the slice into a slice of `N`-element arrays,
/// starting at the beginning of the slice,
/// and a rest slice with length strictly less than `N`.
///
/// # Panics
///
/// Panics if `N` is 0.
/// # Examples
///
/// ```
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let (chunks, rest) = pieced::as_with_rest(&slice);
/// assert_eq!(chunks, &[['l', 'o'], ['r', 'e']]);
/// assert_eq!(rest, &['m']);
/// ```
///
/// If you expect the slice to be an exact multiple, you can combine
/// `let`-`else` with an empty slice pattern (or use [`as_exact`]):
/// ```
/// let slice = ['R', 'u', 's', 't'];
/// let (chunks, []) = pieced::as_with_rest(&slice) else {
/// panic!("slice didn't have even length")
/// };
/// assert_eq!(chunks, &[['R', 'u'], ['s', 't']]);
/// ```
pub const
/// Splits the slice into a slice of `N`-element arrays, assuming that there's no remainder.
///
/// # Panics
///
/// Panics when
/// - The slice splits exactly into `N`-element chunks (aka `self.len() % N == 0`).
/// - `N != 0`.
///
/// # Examples
///
/// ```
/// let slice: &[char] = &['l', 'o', 'r', 'e', 'm', '!'];
/// let chunks: &[[char; 1]] = pieced::as_exact(slice);
/// assert_eq!(chunks, &[['l'], ['o'], ['r'], ['e'], ['m'], ['!']]);
/// let chunks: &[[char; 3]] = pieced::as_exact(slice);
/// assert_eq!(chunks, &[['l', 'o', 'r'], ['e', 'm', '!']]);
/// ```
pub const