diff --git a/src/gopher/type.rs b/src/gopher/type.rs index 0d255fb..b8c3fa2 100644 --- a/src/gopher/type.rs +++ b/src/gopher/type.rs @@ -93,8 +93,8 @@ impl Type { } /// Gopher Item Type to RFC char. - pub fn to_char(self) -> Option { - Some(match self { + pub fn to_char(self) -> char { + match self { Type::Text => '0', Type::Menu => '1', Type::CSOEntity => '2', @@ -118,7 +118,7 @@ impl Type { Type::Calendar => 'c', Type::Xml => 'x', Type::Mailbox => 'M', - }) + } } /// Create a Gopher Item Type from its RFC char code. @@ -154,10 +154,6 @@ impl Type { impl fmt::Display for Type { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if let Some(c) = self.to_char() { - write!(f, "{}", c) - } else { - write!(f, "?") - } + write!(f, "{}", self.to_char()) } } diff --git a/src/phetchdir.rs b/src/phetchdir.rs index b18a598..794bc4f 100644 --- a/src/phetchdir.rs +++ b/src/phetchdir.rs @@ -46,7 +46,7 @@ pub fn append(filename: &str, label: &str, url: &str) -> Result<()> { write!( file, "{}{}\t{}\t{}\t{}\r\n", - u.typ.to_char().unwrap_or('i'), + u.typ.to_char(), label, u.sel, u.host, @@ -76,7 +76,7 @@ pub fn prepend(filename: &str, label: &str, url: &str) -> Result<()> { write!( file, "{}{}\t{}\t{}\t{}\r\n", - url.typ.to_char().unwrap_or('i'), + url.typ.to_char(), label, url.sel, url.host,