From 6ff085c9a9ae5ac5da186ca85e1bd642d6154bec Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 3 Apr 2015 18:32:29 -0700 Subject: [PATCH] Make example function in comment more idiomatic --- src/libcore/result.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index eff04dd590393..5be46a09a95d2 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 { -//! 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") //! } //! } //!