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 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()
}