# 1.0.0[−]Primitive Type tuple

A finite heterogeneous sequence, `(T, U, ..)`.

Let's cover each of those in turn:

Tuples are finite. In other words, a tuple has a length. Here's a tuple of length `3`:

`("hello", 5, 'c');Run`

'Length' is also sometimes called 'arity' here; each tuple of a different length is a different, distinct type.

Tuples are heterogeneous. This means that each element of the tuple can have a different type. In that tuple above, it has the type:

`(&'static str, i32, char)Run`

Tuples are a sequence. This means that they can be accessed by position; this is called 'tuple indexing', and it looks like this:

```let tuple = ("hello", 5, 'c');

assert_eq!(tuple.0, "hello");
assert_eq!(tuple.1, 5);
assert_eq!(tuple.2, 'c');Run```

The sequential nature of the tuple applies to its implementations of various traits. For example, in `PartialOrd` and `Ord`, the elements are compared sequentially until the first non-equal set is found.

For more about tuples, see the book.

# Trait implementations

If every type inside a tuple implements one of the following traits, then a tuple itself also implements it.

Due to a temporary restriction in Rust's type system, these traits are only implemented on tuples of arity 12 or less. In the future, this may change.

# Examples

Basic usage:

```let tuple = ("hello", 5, 'c');

assert_eq!(tuple.0, "hello");Run```

Tuples are often used as a return type when you want to return more than one value:

```fn calculate_point() -> (i32, i32) {
// Don't do a calculation, that's not the point of the example
(4, 5)
}

let point = calculate_point();

assert_eq!(point.0, 4);
assert_eq!(point.1, 5);

// Combining this with patterns can be nicer.

let (x, y) = calculate_point();

assert_eq!(x, 4);
assert_eq!(y, 5);Run```

## Trait Implementations

### `impl<'a, T> RangeBounds<T> for (Bound<&'a T>, Bound<&'a T>) where    T: 'a + ?Sized, `1.28.0[src]

#### `fn contains<U>(&self, item: &U) -> bool where    T: PartialOrd<U>,    U: PartialOrd<T> + ?Sized, `1.35.0[src]

Returns `true` if `item` is contained in the range. Read more

### `impl<T> RangeBounds<T> for (Bound<T>, Bound<T>)`1.28.0[src]

#### `fn contains<U>(&self, item: &U) -> bool where    T: PartialOrd<U>,    U: PartialOrd<T> + ?Sized, `1.35.0[src]

Returns `true` if `item` is contained in the range. Read more

### `impl<A, B, C, D, E, F, G, H, I, J> Hash for (A, B, C, D, E, F, G, H, I, J) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash,    G: Hash,    H: Hash,    I: Hash,    J: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B> Hash for (A, B) where    A: Hash,    B: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F, G, H, I, J, K, L> Hash for (A, B, C, D, E, F, G, H, I, J, K, L) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash,    G: Hash,    H: Hash,    I: Hash,    J: Hash,    K: Hash,    L: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C> Hash for (A, B, C) where    A: Hash,    B: Hash,    C: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F> Hash for (A, B, C, D, E, F) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E> Hash for (A, B, C, D, E) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F, G, H, I> Hash for (A, B, C, D, E, F, G, H, I) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash,    G: Hash,    H: Hash,    I: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A> Hash for (A,) where    A: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F, G, H> Hash for (A, B, C, D, E, F, G, H) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash,    G: Hash,    H: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D> Hash for (A, B, C, D) where    A: Hash,    B: Hash,    C: Hash,    D: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F, G> Hash for (A, B, C, D, E, F, G) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash,    G: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F, G, H, I, J, K> Hash for (A, B, C, D, E, F, G, H, I, J, K) where    A: Hash,    B: Hash,    C: Hash,    D: Hash,    E: Hash,    F: Hash,    G: Hash,    H: Hash,    I: Hash,    J: Hash,    K: Hash + ?Sized, `[src]

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where    H: Hasher, `1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<A, B, C, D, E, F, G, H, I> Ord for (A, B, C, D, E, F, G, H, I) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord,    G: Ord,    H: Ord,    I: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B> Ord for (A, B) where    A: Ord,    B: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E, F, G, H, I, J, K> Ord for (A, B, C, D, E, F, G, H, I, J, K) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord,    G: Ord,    H: Ord,    I: Ord,    J: Ord,    K: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E, F> Ord for (A, B, C, D, E, F) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E, F, G, H> Ord for (A, B, C, D, E, F, G, H) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord,    G: Ord,    H: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E, F, G, H, I, J, K, L> Ord for (A, B, C, D, E, F, G, H, I, J, K, L) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord,    G: Ord,    H: Ord,    I: Ord,    J: Ord,    K: Ord,    L: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A> Ord for (A,) where    A: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E> Ord for (A, B, C, D, E) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D> Ord for (A, B, C, D) where    A: Ord,    B: Ord,    C: Ord,    D: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E, F, G> Ord for (A, B, C, D, E, F, G) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord,    G: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C> Ord for (A, B, C) where    A: Ord,    B: Ord,    C: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl<A, B, C, D, E, F, G, H, I, J> Ord for (A, B, C, D, E, F, G, H, I, J) where    A: Ord,    B: Ord,    C: Ord,    D: Ord,    E: Ord,    F: Ord,    G: Ord,    H: Ord,    I: Ord,    J: Ord + ?Sized, `[src]

#### `fn max(self, other: Self) -> Self`1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self`1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp` #44095)

Restrict a value to a certain interval. Read more

### `impl ToSocketAddrs for (IpAddr, u16)`[src]

#### `type Iter = IntoIter<SocketAddr>`

Returned iterator over socket addresses which this type may correspond to. Read more

### `impl ToSocketAddrs for (Ipv4Addr, u16)`[src]

#### `type Iter = IntoIter<SocketAddr>`

Returned iterator over socket addresses which this type may correspond to. Read more

### `impl ToSocketAddrs for (Ipv6Addr, u16)`[src]

#### `type Iter = IntoIter<SocketAddr>`

Returned iterator over socket addresses which this type may correspond to. Read more

### `impl<'_> ToSocketAddrs for (&'_ str, u16)`[src]

#### `type Iter = IntoIter<SocketAddr>`

Returned iterator over socket addresses which this type may correspond to. Read more