1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Operations on tuples
13 //! To access a single element of a tuple one can use the following
16 //! * `valN` - returns a value of _N_-th element
17 //! * `refN` - returns a reference to _N_-th element
18 //! * `mutN` - returns a mutable reference to _N_-th element
20 //! Indexing starts from zero, so `val0` returns first value, `val1`
21 //! returns second value, and so on. In general, a tuple with _S_
22 //! elements provides aforementioned methods suffixed with numbers
23 //! from `0` to `S-1`. Traits which contain these methods are
24 //! implemented for tuples with up to 12 elements.
26 //! If every type inside a tuple implements one of the following
27 //! traits, then a tuple itself also implements it.
41 //! #[allow(deprecated)]
43 //! let pair = ("pi", 3.14f64);
44 //! assert_eq!(pair.0, "pi");
45 //! assert_eq!(pair.1, 3.14f64);
49 //! Using traits implemented for tuples:
52 //! use std::default::Default;
58 //! let c = b.clone();
61 //! let d : (u32, f32) = Default::default();
62 //! assert_eq!(d, (0u32, 0.0f32));
65 #![doc(primitive = "tuple")]