Skip to main content

UnitTuple

Trait UnitTuple 

Source
pub trait UnitTuple: TupleLen<Len = U0> { }
Expand description

A marker trait for empty tuples (size 0).

This trait is implemented for the unit type () and can be used for type-level programming to identify empty tuples.

§Examples

use tuplities_len::{UnitTuple, TupleLen};
use typenum::U0;

fn is_empty<T: UnitTuple>(_tuple: T) {
    // This function only accepts empty tuples
}

is_empty(()); // This works
// is_empty((1,)); // This would not compile

Part of the tuplities crate.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl UnitTuple for ()

Implementors§