No more syntex for serde_derive

This commit is contained in:
David Tolnay
2016-09-10 21:53:14 -07:00
parent 7cc36a9cd3
commit c34baa1e5f
15 changed files with 611 additions and 859 deletions
+29
View File
@@ -0,0 +1,29 @@
use std::fmt::Display;
use std::cell::Cell;
#[derive(Default)]
pub struct Ctxt {
err_count: Cell<usize>,
}
impl Ctxt {
pub fn new() -> Self {
Default::default()
}
pub fn error<T: Display>(&self, msg: T) {
println!("{}", msg);
self.err_count.set(self.err_count.get() + 1);
}
}
impl Drop for Ctxt {
fn drop(&mut self) {
let err_count = self.err_count.get();
if err_count == 1 {
panic!("1 error");
} else if err_count > 1 {
panic!("{} errors", err_count);
}
}
}