Skip to content

Commit

Permalink
Inline trait impls
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Oct 22, 2023
1 parent ed47106 commit f0d010e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ impl<const N: usize> AsRef<[Underlying; N]> for Primes<N> {
impl<const N: usize> IntoIterator for Primes<N> {
type Item = <[Underlying; N] as IntoIterator>::Item;
type IntoIter = <[Underlying; N] as IntoIterator>::IntoIter;
#[inline]
fn into_iter(self) -> Self::IntoIter {
self.primes.into_iter()
}
Expand All @@ -337,18 +338,21 @@ impl<const N: usize> IntoIterator for Primes<N> {
// region: PartialEq

impl<const N: usize, T: PartialEq<[Underlying; N]>> PartialEq<T> for Primes<N> {
#[inline]
fn eq(&self, other: &T) -> bool {
other == &self.primes
}
}

impl<const N: usize> PartialEq<Primes<N>> for [Underlying; N] {
#[inline]
fn eq(&self, other: &Primes<N>) -> bool {
self == &other.primes
}
}

impl<const N: usize> PartialEq<Primes<N>> for &[Underlying] {
#[inline]
fn eq(&self, other: &Primes<N>) -> bool {
self == &other.primes
}
Expand All @@ -360,18 +364,21 @@ impl<const N: usize> PartialEq<Primes<N>> for &[Underlying] {

use core::cmp::Ordering;
impl<const N: usize, T: PartialOrd<[Underlying; N]>> PartialOrd<T> for Primes<N> {
#[inline]
fn partial_cmp(&self, other: &T) -> Option<Ordering> {
other.partial_cmp(&self.primes)
}
}

impl<const N: usize> PartialOrd<Primes<N>> for [Underlying; N] {
#[inline]
fn partial_cmp(&self, other: &Primes<N>) -> Option<Ordering> {
other.primes.partial_cmp(self)
}
}

impl<const N: usize> PartialOrd<Primes<N>> for &[Underlying] {
#[inline]
fn partial_cmp(&self, other: &Primes<N>) -> Option<Ordering> {
other.primes.as_slice().partial_cmp(self)
}
Expand Down

0 comments on commit f0d010e

Please sign in to comment.