pub trait TupleOption: TupleDefault {
type Transposed: IntoTupleOption<IntoOptions = Self>;
// Required method
fn transpose(self) -> Option<Self::Transposed>;
}Expand description
A trait for transposing a tuple of options into an option of a tuple.
Required Associated Types§
Sourcetype Transposed: IntoTupleOption<IntoOptions = Self>
type Transposed: IntoTupleOption<IntoOptions = Self>
The transposed type: an option of the tuple of the inner types.
Required Methods§
Sourcefn transpose(self) -> Option<Self::Transposed>
fn transpose(self) -> Option<Self::Transposed>
Transposes the tuple of options into an option of the tuple.
Returns Some((a, b, ...)) if all elements are Some, otherwise None.
§Examples
use tuplities_option::TupleOption;
let tuple = (Some(1), Some(2));
let transposed: Option<(i32, i32)> = tuple.transpose();
assert_eq!(transposed, Some((1, 2)));
let tuple = (Some(1), None);
let transposed: Option<(i32, i32)> = tuple.transpose();
assert_eq!(transposed, None);Part of the tuplities crate.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.