Add try!() around write!()

This commit is contained in:
Matthias Beyer 2015-12-30 23:00:30 +01:00
parent 37f3c90914
commit d6bd011d95
6 changed files with 19 additions and 20 deletions

View file

@ -294,7 +294,7 @@ impl<'a> Module<'a> for BM<'a> {
impl<'a> Debug for BM<'a> { impl<'a> Debug for BM<'a> {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "BM"); try!(write!(fmt, "BM"));
Ok(()) Ok(())
} }

View file

@ -47,7 +47,7 @@ impl<'a> Error for MatchError<'a> {
impl<'a> Debug for MatchError<'a> { impl<'a> Debug for MatchError<'a> {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "{}", self.format()); try!(write!(fmt, "{}", self.format()));
Ok(()) Ok(())
} }
@ -56,7 +56,7 @@ impl<'a> Debug for MatchError<'a> {
impl<'a> Display for MatchError<'a> { impl<'a> Display for MatchError<'a> {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "{}", self.format()); try!(write!(fmt, "{}", self.format()));
Ok(()) Ok(())
} }

View file

@ -97,9 +97,9 @@ impl FileID {
impl Debug for FileID { impl Debug for FileID {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "FileID[{:?}]: {:?}", try!(write!(fmt, "FileID[{:?}]: {:?}",
self.id_type, self.id_type,
self.id); self.id));
Ok(()) Ok(())
} }
@ -108,9 +108,9 @@ impl Debug for FileID {
impl Display for FileID { impl Display for FileID {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "FileID[{:?}]: {:?}", try!(write!(fmt, "FileID[{:?}]: {:?}",
self.id_type, self.id_type,
self.id); self.id));
Ok(()) Ok(())
} }

View file

@ -85,7 +85,7 @@ impl File {
impl Display for File { impl Display for File {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, try!(write!(fmt,
"[File] Owner : '{:?}' "[File] Owner : '{:?}'
FileID: '{:?}' FileID: '{:?}'
Header: '{:?}' Header: '{:?}'
@ -93,7 +93,7 @@ impl Display for File {
self.owning_module_name, self.owning_module_name,
self.header, self.header,
self.data, self.data,
self.id); self.id));
Ok(()) Ok(())
} }
@ -102,7 +102,7 @@ impl Display for File {
impl Debug for File { impl Debug for File {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, try!(write!(fmt,
"[File] Owner : '{:?}' "[File] Owner : '{:?}'
FileID: '{:?}' FileID: '{:?}'
Header: '{:?}' Header: '{:?}'
@ -110,7 +110,7 @@ impl Debug for File {
self.owning_module_name, self.owning_module_name,
self.id, self.id,
self.header, self.header,
self.data); self.data));
Ok(()) Ok(())
} }

View file

@ -30,7 +30,7 @@ impl JsonHeaderParser {
impl Display for JsonHeaderParser { impl Display for JsonHeaderParser {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "JsonHeaderParser"); try!(write!(fmt, "JsonHeaderParser"));
Ok(()) Ok(())
} }
@ -39,7 +39,7 @@ impl Display for JsonHeaderParser {
impl Debug for JsonHeaderParser { impl Debug for JsonHeaderParser {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "JsonHeaderParser, Spec: {:?}", self.spec); try!(write!(fmt, "JsonHeaderParser, Spec: {:?}", self.spec));
Ok(()) Ok(())
} }

View file

@ -57,13 +57,13 @@ impl Error for ParserError {
impl Debug for ParserError { impl Debug for ParserError {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "ParserError: {}\n\n", self.summary); try!(write!(fmt, "ParserError: {}\n\n", self.summary));
if let Some(ref e) = self.explanation { if let Some(ref e) = self.explanation {
write!(fmt, "{}\n\n", e); try!(write!(fmt, "{}\n\n", e));
} }
write!(fmt, "On position {}\nin\n{}", self.index, self.parsertext); try!(write!(fmt, "On position {}\nin\n{}", self.index, self.parsertext));
Ok(()) Ok(())
} }
@ -72,10 +72,10 @@ impl Debug for ParserError {
impl Display for ParserError { impl Display for ParserError {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "ParserError: {}", self.summary); try!(write!(fmt, "ParserError: {}", self.summary));
if let Some(ref e) = self.explanation { if let Some(ref e) = self.explanation {
write!(fmt, "\n\n{}", e); try!(write!(fmt, "\n\n{}", e));
} }
Ok(()) Ok(())
@ -196,8 +196,7 @@ impl<HP> Debug for Parser<HP>
{ {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "Parser<{:?}>", self.headerp); try!(write!(fmt, "Parser<{:?}>", self.headerp));
Ok(()) Ok(())
} }