Make example function in comment more idiomatic

This commit is contained in:
Corey Farwell 2015-04-03 18:32:29 -07:00
parent f207ecbe02
commit 6ff085c9a9
1 changed files with 5 additions and 7 deletions

View File

@ -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")
//! }
//! }
//!