//! Extensions pub trait JoinStrsExt: Sized { /// Join an iterator of `str` with a seperator fn join(self, with: &str) -> String; } impl JoinStrsExt for I where I: Iterator, T: AsRef { fn join(self, with: &str) -> String { let mut output = String::new(); let mut first=true; for string in self { if !first { output.push_str(with); } let string = string.as_ref(); output.push_str(string); first=false; } output } } /*macro_rules! typed_swap { (@ [] $($reversed:tt)*) => { fn swap(self) -> ($($reversed)*); }; (@ [$first:tt $($rest:tt)*] $($reversed:tt)*) => { typed_swap!{@ [$($rest)*] $first $($reversed)*} }; (@impl {$($body:tt)*} [] $($reversed:tt)*) => { fn swap(self) -> ($($reversed)*) { $($body)* } }; (@impl {$($body:tt)*} [$first:tt $($rest:tt)*] $($reversed:tt)*) => { typed_swap!{@impl {$($body)*} [$($rest)*] $first $($reversed)*} }; () => {}; ({$($params:tt)*} $($rest:tt)*) => { mod swap { pub trait SwapTupleExt<$($params)*>: Sized { typed_swap!(@ [$($params)*]); } impl<$($params)*> SwapTupleExt<$($params)*> for ($($params)*) { typed_swap!(@impl { todo!() } [$($params)*]); } typed_swap!($($rest)*); } pub use swap::*; }; (all $first:tt $($params:tt)+) => { typed_swap!({$first, $($params),+}); mod nswap { typed_swap!(all $($params)+); } }; (all $($one:tt)?) => {}; } typed_swap!(all A B C D E F G H I J K L M N O P Q R S T U V W X Y Z); pub use swap::*; fn test() { let sw = (1, 2).swap(); }*/ // ^ unfortunately not lol pub trait SwapTupleExt: Sized { fn swap(self) -> (U,T); } impl SwapTupleExt for (T,U) { #[inline(always)] fn swap(self) -> (U,T) { (self.1, self.0) } } /*typed_swap!({A, B} {A, U, V} {T, U, V, W});*/