tuplities_remove/
lib.rs

1//! A trait for removing elements at specific indices from tuples.
2//!
3//! This crate provides the `TupleRemove<Idx>` trait, which allows removing an element
4//! at a compile-time known index from a tuple, returning the element and the
5//! remaining tuple.
6
7#![no_std]
8
9/// A trait for removing an element at a specific index from a tuple.
10///
11/// This trait allows removing an element at compile-time known index `Idx`
12/// from a tuple, returning the element and the remaining tuple.
13///
14/// # Examples
15///
16/// ```
17/// use tuplities_remove::TupleRemove;
18/// use typenum::U1;
19///
20/// let tuple = (1, "hello", 3.14);
21/// let (removed, remainder) = TupleRemove::<U1>::remove(tuple);
22/// assert_eq!(removed, "hello");
23/// assert_eq!(remainder, (1, 3.14));
24/// ```
25#[tuplities_derive::impl_remove]
26pub trait TupleRemove<Idx: typenum::Unsigned> {
27    /// The type of the element being removed.
28    type Type;
29
30    /// The type of the remaining tuple after removing.
31    type Remainder;
32
33    /// Removes the element at index `Idx` from the tuple.
34    ///
35    /// Returns a tuple containing the removed element and the remaining tuple.
36    fn remove(self) -> (Self::Type, Self::Remainder);
37}