summary refs log tree commit diff
path: root/src/libstd/tuple.rs
diff options
context:
space:
mode:
authorFakeKane <andrewyli@gmail.com>2015-01-05 16:22:03 -0500
committerFakeKane <andrewyli@gmail.com>2015-01-05 16:22:03 -0500
commit8733b8b19c510737faed35b83fdecc1c41a96a27 (patch)
treec440f9376cd8845de49accb1dc6a9747754890fa /src/libstd/tuple.rs
parent05c5b5f03392edb9df8515f645883edd0bd8b816 (diff)
downloadrust-8733b8b19c510737faed35b83fdecc1c41a96a27.tar.gz
rust-8733b8b19c510737faed35b83fdecc1c41a96a27.zip
examples added for element access
Diffstat (limited to 'src/libstd/tuple.rs')
-rw-r--r--src/libstd/tuple.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs
index a12844f039e..0c8273abde4 100644
--- a/src/libstd/tuple.rs
+++ b/src/libstd/tuple.rs
@@ -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.
@@ -28,6 +28,17 @@
 //! * `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:
 //!