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
use ress::prelude::*; /// A comment handler will allow you to specify /// behavior about what to do with comments /// officially comments are supposed to operate /// the same as whitespace so the default behavior /// would be to throw away any comments found pub trait CommentHandler<'a> { fn handle_comment(&mut self, comment: Item<Token<&'a str>>); } /// The default comment handler, /// this will discard comments /// provided to it pub struct DefaultCommentHandler; impl<'a> CommentHandler<'a> for DefaultCommentHandler { fn handle_comment(&mut self, _: Item<Token<&'a str>>) {} } impl<'a, F> CommentHandler<'a> for F where F: FnMut(Item<Token<&'a str>>), { fn handle_comment(&mut self, item: Item<Token<&'a str>>) { self(item) } }