Skip to content

Commit

Permalink
Makes len() as inline
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Mar 27, 2024
1 parent c3da0d1 commit 9ef1fad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ macro_rules! count {
macro_rules! tuple_impl {
($( $T:ident ),*) => {
impl<$( $T, )*> TupleLen for ($( $T, )*) {
#[inline]
fn len(&self) -> usize {
count!($( $T )*)
}
}

impl<$( $T, )*> TupleLen for &($( $T, )*) {
#[inline]
fn len(&self) -> usize {
count!($( $T )*)
}
Expand All @@ -51,6 +53,7 @@ tuple_impl!(A, B, C, D, E, F, G, H, I, J);
tuple_impl!(A, B, C, D, E, F, G, H, I, J, K);
tuple_impl!(A, B, C, D, E, F, G, H, I, J, K, L);

#[inline]
pub fn len(tuple: impl TupleLen) -> usize {
tuple.len()
}
Expand Down

0 comments on commit 9ef1fad

Please sign in to comment.