pub trait TupleInsert<T> {
// Provided method
fn insert<const POS: usize>(self, val: T) -> Self::Output
where Self: TupleInsertExact<POS, T> + Sized { ... }
}
Expand description
Insert a value into a tuple.
Unlike TupleInsertExact
, this trait moves the const POS
to a method,
so it can be used with the help of type derivation
without explicitly declaring the underlying trait.
§Example
use rs_std_ext::tuple::TupleInsert;
let x = (10u8, 'a');
let y = x.insert::<1>(-5i32);
assert_eq!(y, (10u8, -5i32, 'a'));