pub trait TupleAppend<T> {
type ResultType;
fn append(self, t: T) -> Self::ResultType;
}
impl<T> TupleAppend<T> for () {
type ResultType = (T,);
fn append(self, t: T) -> Self::ResultType {
(t,)
}
}
macro_rules! impl_tuple_append {
( () ) => {};
( ( $t0:ident $(, $types:ident)* ) ) => {
impl<$t0, $($types,)* T> TupleAppend<T> for ($t0, $($types,)*) {
type ResultType = ($t0, $($types,)* T,);
fn append(self, t: T) -> Self::ResultType {
let ($t0, $($types,)*) = self;
($t0, $($types,)* t,)
}
}
impl_tuple_append! { ($($types),*) }
};
}
impl_tuple_append! {
(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12)
}
#[test]
fn test_tuple_append() {
let some_tuple: (i32, &str, bool) = (1, "Hello", true);
println!("{:?}", some_tuple);
let n: (u16, u16) = [3, 4].into();
println!("{:?}", n);
let with_world: (i32, &str, bool, &str) = some_tuple.append("World");
println!("{:?}", with_world);
}
use http::Uri;
use impl_trait_for_tuples::impl_for_tuples;
pub trait Tuple {
fn simbol_of_to_tuple(self) -> Self;
}
#[impl_for_tuples(0, 12)]
impl Tuple for TupleIdentifier {
fn simbol_of_to_tuple(self) -> Self {
self
}
}
use derive_more::{AsRef, Deref, DerefMut, Display, From};
use urlpattern::{UrlPattern, UrlPatternInit};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Deref, DerefMut, AsRef, Display, From)]
pub struct Path<T>(T);
impl<T> Path<T>
{
pub fn into_inner(self) -> T {
self.0
}
pub fn new(t: T) -> Path<T> {
Self(t)
}
}