Skip to content

Commit

Permalink
add "teaser-trailer" of using typnum internally
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-PH committed May 3, 2024
1 parent 001a667 commit bdad2d1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/hlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub trait HList: Sized {
/// assert_eq!(h.len(), 2);
/// # }
/// ```
#[deprecated(since = "0.5.0", note = "Please use Len::USIZE instead")]
#[deprecated(since = "0.5.0", note = "Please use <Self as HList>::Len::[USIZE | U8 | U32 | ... ] instead")]
#[inline]
fn len(&self) -> usize {
<Self::Len as Unsigned>::USIZE
Expand Down Expand Up @@ -266,6 +266,9 @@ macro_rules! gen_inherent_methods {
pub fn len(&self) -> usize
where Self: HList,
{
// this is how it's done at the type-level
// <Self as HList>::Len::USIZE
#[allow(deprecated)]
HList::len(self)
}

Expand All @@ -286,6 +289,8 @@ macro_rules! gen_inherent_methods {
where Self: HList,
{
HList::is_empty(self)
// this is how it's done at the type-level
// <<<Self as HList>::Len as typenum::IsEqual<typenum::U0>>::Output as typenum::Bit>::BOOL
}

/// Prepend an item to the current HList
Expand Down

0 comments on commit bdad2d1

Please sign in to comment.