Skip to main content

Enumerable

Trait Enumerable 

Source
pub trait Enumerable: TupleLike {
    type EnumerateOutput: TupleLike;

    // Required method
    fn enumerate(self, from: usize) -> Self::EnumerateOutput;
}
Expand description

Convert from tuple!(x, y, z, ...) to tuple!((0, x), (1, y), (2, z), ...).

Required Associated Types§

Source

type EnumerateOutput: TupleLike

The type of the output tuple.

Required Methods§

Source

fn enumerate(self, from: usize) -> Self::EnumerateOutput

Convert from tuple!(x, y, z, ...) to tuple!((0, x), (1, y), (2, z), ...).

Hint: The TupleLike trait provides the enumerate() method as the wrapper for this enumerate() method.

§Example
use tuplez::{tuple, TupleLike};
 
let tup = tuple!("hello", Some([1, 2, 3]), tuple!(3.14, 12));
assert_eq!(tup.enumerate(), tuple!(
    (0, "hello"),
    (1, Some([1, 2, 3])),
    (2, tuple!(3.14, 12)),
));

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Enumerable for Unit

Source§

impl<First, Other> Enumerable for Tuple<First, Other>
where Other: Enumerable,