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 push an element into some sort of storage.
pub trait Push {
  /// Input type for the [`push`](Push::push)` method.
  type Input;
  /// Output type for the [`push`](Push::push)` method.
  type Output;

  /// Pushes an element
  fn push(&mut self, input: Self::Input) -> Self::Output;
}

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

  fn push(&mut self, input: Self::Input) -> Self::Output {
    self.push(input);
  }
}

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

  fn push(&mut self, input: Self::Input) -> Self::Output {
    self.push(input);
  }
}

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

  fn push(&mut self, input: Self::Input) -> Self::Output {
    self.push(input);
  }
}

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

  fn push(&mut self, input: Self::Input) -> Self::Output {
    self.push(input);
  }
}