1
0
Fork 0
forked from wry/wry

autocommit 2022-01-08 19:02:10 CET

This commit is contained in:
Julian Orth 2022-01-08 19:02:11 +01:00
parent d061a5c313
commit 3336f1ab6a
37 changed files with 243 additions and 136 deletions

View file

@ -59,7 +59,7 @@ impl<'a, 'b> MsgParser<'a, 'b> {
#[allow(dead_code)]
pub fn fixed(&mut self) -> Result<Fixed, MsgParserError> {
self.int().map(|i| Fixed(i))
self.int().map(Fixed)
}
pub fn string(&mut self) -> Result<&'b BStr, MsgParserError> {

21
src/utils/errorfmt.rs Normal file
View file

@ -0,0 +1,21 @@
use std::error::Error;
use std::fmt::{Display, Formatter};
pub struct ErrorFmt<E>(pub E);
impl<E: Error> Display for ErrorFmt<E> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut e_opt = Some(&self.0 as &dyn Error);
let mut first = true;
while let Some(e) = e_opt {
if first {
write!(f, "{}", e)?;
first = false;
} else {
write!(f, ": {}", e)?;
}
e_opt = e.source();
}
Ok(())
}
}

View file

@ -1,6 +1,7 @@
pub mod asyncevent;
pub mod buffd;
pub mod copyhashmap;
pub mod errorfmt;
pub mod linkedlist;
pub mod numcell;
pub mod oneshot;