diff --git a/macros/src/lib.rs b/macros/src/lib.rs index a085a6b..2cd4cf6 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -2,13 +2,12 @@ use std::fs; use proc_macro::TokenStream; use quote::{format_ident, quote}; +use syn::{parse, Result}; use syn::{ - buffer::Cursor, - parse::{Parse, ParseStream, StepCursor}, + parse::{Parse, ParseStream}, spanned::Spanned, Error, Ident, Lit, LitInt, }; -use syn::{parse, Result}; const DATA_DIR: &str = "data"; const EXAMPLE_DIR: &str = "examples"; @@ -112,7 +111,7 @@ pub fn include_data(data: TokenStream) -> TokenStream { Some(p) => { return quote! { #[doc = #comment] - static #ident: &str = include_str!(#p); + const #ident: &str = include_str!(#p).trim_ascii(); } .into() } @@ -126,7 +125,7 @@ pub fn include_data(data: TokenStream) -> TokenStream { } quote! { #[doc = #comment] - static #ident: &str = ""; + const #ident: &str = ""; } .into() } @@ -147,7 +146,7 @@ pub fn include_example(data: TokenStream) -> TokenStream { Some(p) => { return quote! { #[doc = #comment] - static #ident: &str = include_str!(#p); + const #ident: &str = include_str!(#p).trim_ascii(); } .into() } @@ -161,7 +160,7 @@ pub fn include_example(data: TokenStream) -> TokenStream { } quote! { #[doc = #comment] - static #ident: &str = ""; + const #ident: &str = ""; } .into() }