pub trait RepeatedTuple<E>: Sized {
// Required method
fn to_boxed_slice_reversed(self) -> Box<[E]>;
// Provided methods
fn to_boxed_slice(self) -> Box<[E]> { ... }
fn to_vec_reversed(self) -> Vec<E> { ... }
fn to_vec(self) -> Vec<E> { ... }
}
Expand description
A trait implemented on all tuples composed of a single type.1
The available methods for this trait are what make up the standard way to
use this crate. Importing RepeatedTuple
allows these methods to be called
directly on types you’re working with. This trait can also be used loosely
as a bound specifically for repeated tuples, though there’s nothing
stopping someone from implementing it on their own type.
A particularly nice use case of RepeatedTuple
is ensuring a nice syntax
for your API. Because this is already discussed in the
crate-level documentation, more examples will not be given here.
§A few notes:
While this trait can be used as a trait bound, you may find it better
to instead use TupleOrVec
, as it also encapsulates vectors.
Additionally, while it is true in practice, there is no blanket
implementation of TupleOrVec
for all RepeatedTuple
, due to compiler
constraints.
Finally: The typical use case does not recommend or require re-implementing this trait, but nothing will break if you do.
Please note that this is only implemented for tuples up to size 64. If you need more than 64, please fork this crate or submit a pull request. ↩
Required Methods§
Sourcefn to_boxed_slice_reversed(self) -> Box<[E]>
fn to_boxed_slice_reversed(self) -> Box<[E]>
Converts a tuple to a boxed slice, with elements in reverse order
Provided Methods§
Sourcefn to_boxed_slice(self) -> Box<[E]>
fn to_boxed_slice(self) -> Box<[E]>
Converts a tuple to a boxed slice of its elements
Sourcefn to_vec_reversed(self) -> Vec<E>
fn to_vec_reversed(self) -> Vec<E>
Converts a tuple to a vector, with elements in reverse order
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.