syn_prelude/
with_suffix.rs

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