Macro tuplez::split_at

source ·
split_at!() { /* proc-macro */ }
Expand description

Split the tuple into two tuples at a specific index.

§Syntax

split_at!(Expr; Index)

The index must be an integer literal since procedural macros do not yet support evaluating constants.

§Examples

use tuplez::*;

let tup = tuple!(1, "hello", 3.14, [1, 2, 3]);

let (left, right) = split_at!(tup; 2);
assert_eq!(left, tuple!(1, "hello"));
assert_eq!(right, tuple!(3.14, [1, 2, 3]));

let (left, right) = split_at!(tup; 0);
assert_eq!(left, tuple!());
assert_eq!(right, tup);

let (left, right) = split_at!(tup; 4);
assert_eq!(left, tup);
assert_eq!(right, tuple!());