We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 563cf10 + 6ff085c commit 61e0aafCopy full SHA for 61e0aaf
src/libcore/result.rs
@@ -34,13 +34,11 @@
34
//! enum Version { Version1, Version2 }
35
//!
36
//! fn parse_version(header: &[u8]) -> Result<Version, &'static str> {
37
-//! if header.len() < 1 {
38
-//! return Err("invalid header length");
39
-//! }
40
-//! match header[0] {
41
-//! 1 => Ok(Version::Version1),
42
-//! 2 => Ok(Version::Version2),
43
-//! _ => 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")
44
//! }
45
46
0 commit comments