Method implementations for tuples
Tuples are fixed-size collections of elements of different types. They are often used to return multiple values from a function or to group values of different types together.
A single-element tuple is represented as (T,)
, where T
is the type of the element. An empty
tuple ()
is also known as void.
Methods
impl tuple<Tup> { ... }
Tup: Tuple
-
fn len(self: &Tup) -> usize
Returns the number of elements in the tuple.
Example
let tuple = (1, 2, 3); assert_eq!(tuple.len(), 3);
Run this example -
fn equals(lhs: &Tup, rhs: &Tup) -> bool
-
fn compare(lhs: &Tup, rhs: &Tup) -> Ordering
-
fn hash<H>(lhs: &Tup, h: &mut H)
H: Hasher<H>
Mixins
impl tuple<Tup> { ... }
Tup: Tuple
-
mixin Equatable<Tup>
-
Returns
false
if arguments are equal,true
otherwise -
mixin Comparable<Tup>
-
Returns
true
iflhs
is strictly less thanrhs
,false
otherwise -
Returns
true
iflhs
is less or equal torhs
,false
otherwise -
Returns
true
iflhs
strictly greater thanrhs
,false
otherwise -
Returns
true
iflhs
greater than or equalrhs
,false
otherwise