Function timrs_macro_utils::test::parse_test
source · pub fn parse_test<T: Parse>(tokens: TokenStream) -> Result<T, TokenStream>
Expand description
Pretty prints a proc_macro2::TokenStream
to a String
.
§Examples
use core::str::FromStr;
use proc_macro2::TokenStream;
use syn::{Ident};
use timrs_macro_utils::test::{build_tokens, parse_test};
assert_eq!(
parse_test::<Ident>(build_tokens("a")).map(|value| value.to_string()).unwrap(),
"a"
);
§Errors
Will return a proc_macro2::TokenStream
containing a compiler error in case parsing fails.