autocommit 2022-01-08 19:02:10 CET
This commit is contained in:
parent
d061a5c313
commit
3336f1ab6a
37 changed files with 243 additions and 136 deletions
|
|
@ -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
21
src/utils/errorfmt.rs
Normal 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(())
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue