about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2015-04-03 18:32:29 -0700
committerCorey Farwell <coreyf@rwell.org>2015-04-03 18:32:29 -0700
commit6ff085c9a9ae5ac5da186ca85e1bd642d6154bec (patch)
tree9637bddbcb8467f96c02318a708699351623bfd1
parentf207ecbe021e2a81fbff4ea1904b955a156aa340 (diff)
downloadrust-6ff085c9a9ae5ac5da186ca85e1bd642d6154bec.tar.gz
rust-6ff085c9a9ae5ac5da186ca85e1bd642d6154bec.zip
Make example function in comment more idiomatic
-rw-r--r--src/libcore/result.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index eff04dd5903..5be46a09a95 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -34,13 +34,11 @@
 //! enum Version { Version1, Version2 }
 //!
 //! fn parse_version(header: &[u8]) -> Result<Version, &'static str> {
-//!     if header.len() < 1 {
-//!         return Err("invalid header length");
-//!     }
-//!     match header[0] {
-//!         1 => Ok(Version::Version1),
-//!         2 => Ok(Version::Version2),
-//!         _ => Err("invalid version")
+//!     match header.get(0) {
+//!         None => Err("invalid header length"),
+//!         Some(&1) => Ok(Version::Version1),
+//!         Some(&2) => Ok(Version::Version2),
+//!         Some(_) => Err("invalid version")
 //!     }
 //! }
 //!