syn_prelude/
with_prefix.rs1use proc_macro2::Ident;
2use syn::LitStr;
3
4pub trait WithPrefix {
5 fn with_prefix<S: AsRef<str>>(&self, prefix: S) -> Self;
6}
7
8impl WithPrefix for Ident {
9 fn with_prefix<S: AsRef<str>>(&self, prefix: S) -> Self {
10 Self::new(
11 &format!("{}{}", prefix.as_ref(), self.to_string()),
12 self.span(),
13 )
14 }
15}
16
17impl WithPrefix for LitStr {
18 fn with_prefix<S: AsRef<str>>(&self, prefix: S) -> Self {
19 Self::new(&format!("{}{}", prefix.as_ref(), self.value()), self.span())
20 }
21}