Skip to content

Commit

Permalink
count_ident macro without any comma
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe-Cholet authored and phimuemue committed Oct 27, 2023
1 parent baaf852 commit d188e8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/adaptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,15 +749,15 @@ macro_rules! impl_tuple_combination {
}

fn size_hint(&self) -> SizeHint {
const K: usize = 1 + count_ident!($($X,)*);
const K: usize = 1 + count_ident!($($X)*);
let (mut n_min, mut n_max) = self.iter.size_hint();
n_min = checked_binomial(n_min, K).unwrap_or(usize::MAX);
n_max = n_max.and_then(|n| checked_binomial(n, K));
size_hint::add(self.c.size_hint(), (n_min, n_max))
}

fn count(self) -> usize {
const K: usize = 1 + count_ident!($($X,)*);
const K: usize = 1 + count_ident!($($X)*);
let n = self.iter.count();
checked_binomial(n, K).unwrap() + self.c.count()
}
Expand Down
2 changes: 1 addition & 1 deletion src/impl_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ macro_rules! ignore_ident{

macro_rules! count_ident {
() => {0};
($i0:ident, $($i:ident,)*) => {1 + count_ident!($($i,)*)};
($i0:ident $($i:ident)*) => {1 + count_ident!($($i)*)};
}
4 changes: 2 additions & 2 deletions src/tuple_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ macro_rules! impl_tuple_collect {
impl_tuple_collect!($($Y,)*);
impl<A> TupleCollect for ($(ignore_ident!($Y, A),)*) {
type Item = A;
type Buffer = [Option<A>; count_ident!($($Y,)*) - 1];
type Buffer = [Option<A>; count_ident!($($Y)*) - 1];

#[allow(unused_assignments, unused_mut)]
fn collect_from_iter<I>(iter: I, buf: &mut Self::Buffer) -> Option<Self>
Expand Down Expand Up @@ -388,7 +388,7 @@ macro_rules! impl_tuple_collect {
}

fn num_items() -> usize {
count_ident!($($Y,)*)
count_ident!($($Y)*)
}

fn left_shift_push(&mut self, mut item: A) {
Expand Down

0 comments on commit d188e8e

Please sign in to comment.