//! Tuple traits use super::*; pub trait TryUntupleTwoExt: Sized { type Wrapper; fn both(self) -> Self::Wrapper<(T, U)>; } impl TryUntupleTwoExt for (T, Option) { type Wrapper = Option; #[inline] fn both(self) -> Self::Wrapper<(T, U)> { match self { (first, Some(second)) => Some((first, second)), _ => None, } } } impl TryUntupleTwoExt for (Option, U) { type Wrapper = Option; #[inline] fn both(self) -> Self::Wrapper<(T, U)> { match self { (Some(first), second) => Some((first, second)), _ => None, } } } impl TryUntupleTwoExt for (Option, Option) { type Wrapper = Option; #[inline] fn both(self) -> Self::Wrapper<(T, U)> { match self { (Some(first), Some(second)) => Some((first, second)), _ => None, } } } pub trait UntupleTwoExt: Sized { type Unwrapped; fn untuple(self) -> Self::Unwrapped; } impl UntupleTwoExt for (T, (U, V)) { type Unwrapped = (A,B,C); #[inline] fn untuple(self) -> Self::Unwrapped { (self.0, self.1.0, self.1.1) } } impl UntupleTwoExt for (T, (U,)) { type Unwrapped = (A,B); #[inline] fn untuple(self) -> Self::Unwrapped { (self.0, self.1.0) } } impl UntupleTwoExt for (T,) { type Unwrapped = A; #[inline] fn untuple(self) -> Self::Unwrapped { self.0 } }