]> git.lizzy.rs Git - rust.git/commitdiff
examples added for element access
authorFakeKane <andrewyli@gmail.com>
Mon, 5 Jan 2015 21:22:03 +0000 (16:22 -0500)
committerFakeKane <andrewyli@gmail.com>
Mon, 5 Jan 2015 21:22:03 +0000 (16:22 -0500)
src/libstd/tuple.rs

index a12844f039ec6b4c1779aff4ec634712a722965a..0c8273abde40ab2740f3a62eaf9fa81b71f3b02d 100644 (file)
@@ -15,7 +15,7 @@
 //!
 //! Indexing starts from zero, so `0` returns first value, `1`
 //! returns second value, and so on. In general, a tuple with _S_
-//! elements provides aforementioned fields from `0` to `S-1`
+//! elements provides aforementioned fields from `0` to `S-1`.
 //!
 //! If every type inside a tuple implements one of the following
 //! traits, then a tuple itself also implements it.
 //! * `Default`
 //!
 //! # Examples
+//! 
+//! Accessing elements of a tuple at specified indices:
+//! 
+//! ```
+//! let x = ("colorless",  "green", "ideas", "sleep", "furiously");
+//! assert_eq!(x.3, "sleep");
+//! 
+//! let v = (3i, 3i);
+//! let u = (1i, -5i);
+//! assert_eq!(v.0 * u.0 + v.1 * u.1, -12i);
+//! ```
 //!
 //! Using traits implemented for tuples:
 //!