99// except according to those terms.
1010
1111//! Operations on tuples
12-
13- #![ allow( missing_doc) ]
12+ //!
13+ //! To access a single element of a tuple one can use the following
14+ //! methods:
15+ //!
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
19+ //!
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.
25+ //!
26+ //! If every type inside a tuple implements one of the following
27+ //! traits, then a tuple itself also implements it.
28+ //!
29+ //! * `Clone`
30+ //! * `Eq`
31+ //! * `TotalEq`
32+ //! * `Ord`
33+ //! * `TotalOrd`
34+ //! * `Default`
35+ //!
36+ //! # Examples
37+ //!
38+ //! Using methods:
39+ //!
40+ //! ```
41+ //! let pair = ("pi", 3.14);
42+ //! assert_eq!(pair.val0(), "pi");
43+ //! assert_eq!(pair.val1(), 3.14);
44+ //! ```
45+ //!
46+ //! Using traits implemented for tuples:
47+ //!
48+ //! ```
49+ //! use std::default::Default;
50+ //!
51+ //! let a = (1, 2);
52+ //! let b = (3, 4);
53+ //! assert!(a != b);
54+ //!
55+ //! let c = b.clone();
56+ //! assert!(b == c);
57+ //!
58+ //! let d : (u32, f32) = Default::default();
59+ //! assert_eq!(d, (0u32, 0.0f32));
60+ //! ```
1461
1562use clone:: Clone ;
1663#[ cfg( not( test) ) ] use cmp:: * ;
@@ -26,6 +73,7 @@ macro_rules! tuple_impls {
2673 }
2774 ) +) => {
2875 $(
76+ #[ allow( missing_doc) ]
2977 pub trait $Tuple<$( $T) ,+> {
3078 $( fn $valN( self ) -> $T; ) +
3179 $( fn $refN<' a>( & ' a self ) -> & ' a $T; ) +
0 commit comments