diff --git a/src/main.rs b/src/main.rs index e24511e..45861c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ #![feature(macro_rules)] -use nom::{feed, parse, Error, Done, Incomplete}; +use nom::{feed, parse, print, Error, Done, Incomplete}; mod nom; @@ -13,4 +13,6 @@ fn main() { } feed(); + let v2 = "abc"; + print(&v2); } diff --git a/src/nom.rs b/src/nom.rs index 25c9c3a..1e35b7a 100644 --- a/src/nom.rs +++ b/src/nom.rs @@ -3,6 +3,8 @@ extern crate collections; +use std::fmt::Show; + type Err = uint; pub enum Parser<'a,I,O> { Done(I,O), @@ -55,3 +57,7 @@ pub fn parse<'a>(input: &'a [u8]) -> Parser<'a, &'a [u8], &'a [u8]> { } } +pub fn print<'a, T: Show>(input: &'a T) -> Parser<'a, (), ()> { + println!("{}", input); + Done((), ()) +}