Lokathor / tinyvec

Just, really the littlest Vec you could need. So smol.
https://docs.rs/tinyvec
Apache License 2.0
648 stars 49 forks source link

generated_impl.rs can be simpler #182

Closed wolfnether closed 1 year ago

wolfnether commented 1 year ago

impl<T: Default, const S: usize> Array for [T; S] {
  type Item = T;
  const CAPACITY: usize = S;

  #[inline(always)]
  #[must_use]
  fn as_slice(&self) -> &[T] {
    &*self
  }

  #[inline(always)]
  #[must_use]
  fn as_slice_mut(&mut self) -> &mut [T] {
    &mut *self
  }

  #[inline(always)]
  fn default() -> Self {
    [(); S].map(|_| T::default())
  }
}