Skip to content

Commit

Permalink
Use metavar ${count(x)} instead of reimplementing it
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed May 2, 2023
1 parent 9fba262 commit 4d04a06
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions library/core/src/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ macro_rules! tuple_impls {
}

#[stable(feature = "array_tuple_conv", since = "1.63.0")]
impl<T> From<[T; count!($($T)+)]> for ($(${ignore(T)} T,)+) {
impl<T> From<[T; ${count(T)}]> for ($(${ignore(T)} T,)+) {
#[inline]
#[allow(non_snake_case)]
fn from(array: [T; count!($($T)+)]) -> Self {
fn from(array: [T; ${count(T)}]) -> Self {
let [$($T,)+] = array;
($($T,)+)
}
}

#[stable(feature = "array_tuple_conv", since = "1.63.0")]
impl<T> From<($(${ignore(T)} T,)+)> for [T; count!($($T)+)] {
impl<T> From<($(${ignore(T)} T,)+)> for [T; ${count(T)}] {
#[inline]
#[allow(non_snake_case)]
fn from(tuple: ($(${ignore(T)} T,)+)) -> Self {
Expand Down Expand Up @@ -200,12 +200,6 @@ macro_rules! last_type {

tuple_impls!(E D C B A Z Y X W V U T);

macro_rules! count {
($($a:ident)*) => {
0 $(${ignore(a)} + 1)*
};
}

#[stable(feature = "array_tuple_conv", since = "1.63.0")]
impl<T> From<()> for [T; 0] {
fn from((): ()) -> Self {
Expand Down

0 comments on commit 4d04a06

Please sign in to comment.