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
/// Has some way to truncate some sort of storage.
pub trait Truncate {
  /// Input type for the [`truncate`](Truncate::truncate)` method.
  type Input;
  /// Output type for the [`truncate`](Truncate::truncate)` method.
  type Output;

  /// Truncates the storage.
  fn truncate(&mut self, input: Self::Input) -> Self::Output;
}

#[cfg(feature = "alloc")]
impl<T> Truncate for alloc::vec::Vec<T> {
  type Input = usize;
  type Output = ();

  fn truncate(&mut self, input: Self::Input) {
    self.truncate(input)
  }
}

#[cfg(feature = "with_arrayvec")]
impl<A> Truncate for arrayvec::ArrayVec<crate::ArrayWrapper<A>>
where
  A: crate::Array,
{
  type Input = usize;
  type Output = ();

  fn truncate(&mut self, input: Self::Input) {
    self.truncate(input)
  }
}

#[cfg(feature = "with_smallvec")]
impl<A> Truncate for smallvec::SmallVec<crate::ArrayWrapper<A>>
where
  A: crate::Array,
{
  type Input = usize;
  type Output = ();

  fn truncate(&mut self, input: Self::Input) {
    self.truncate(input)
  }
}

#[cfg(feature = "with_staticvec")]
impl<T, const N: usize> Truncate for staticvec::StaticVec<T, N> {
  type Input = usize;
  type Output = ();

  fn truncate(&mut self, input: Self::Input) {
    self.truncate(input)
  }
}