converted the variable to const and added a trim.

Dieser Commit ist enthalten in:
Sebastian Tobie 2024-12-03 18:44:06 +01:00
Ursprung 013e2470b2
Commit 08662acb1d

Datei anzeigen

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