1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
use de::{Map, Seq, Visitor}; use error::Result; impl Visitor { pub fn ignore() -> &'static mut Visitor { careful!(&mut Ignore as &mut Ignore) } } struct Ignore; impl Visitor for Ignore { fn null(&mut self) -> Result<()> { Ok(()) } fn boolean(&mut self, _b: bool) -> Result<()> { Ok(()) } fn string(&mut self, _s: &str) -> Result<()> { Ok(()) } fn negative(&mut self, _n: i64) -> Result<()> { Ok(()) } fn nonnegative(&mut self, _n: u64) -> Result<()> { Ok(()) } fn float(&mut self, _n: f64) -> Result<()> { Ok(()) } fn seq(&mut self) -> Result<Box<Seq + '_>> { Ok(Box::new(Ignore)) } fn map(&mut self) -> Result<Box<Map + '_>> { Ok(Box::new(Ignore)) } } impl Seq for Ignore { fn element(&mut self) -> Result<&mut Visitor> { Ok(Visitor::ignore()) } fn finish(&mut self) -> Result<()> { Ok(()) } } impl Map for Ignore { fn key(&mut self, _k: &str) -> Result<&mut Visitor> { Ok(Visitor::ignore()) } fn finish(&mut self) -> Result<()> { Ok(()) } }