xso-proc: completely overengineer everything for no good reason!
Well, not really, of course. All of this will make sense once we start adding support for fields and non-struct types. Refactoring the code now before we start to add actual member field parsing is much easier. How do I know that this will work out? Well, my crystal ball knows it. Don't believe me? Okay, ChatGPT told me ... Alright alright, I went through the entire process of implementing this feature *twice* at this point and have a pretty good idea of where to draw the abstraction lines so that everything falls neatly into place. You'll have to trust me on this one. (Or, you know, check out old branches in my xmpp-rs repo. That might work, too. `feature/derive-macro-streaming-full` might be a name to look for if you dare.)
This commit is contained in:
parent
bf7816d321
commit
183bef5cf6
10 changed files with 930 additions and 135 deletions
|
|
@ -9,8 +9,6 @@
|
|||
//! This module is concerned with parsing attributes from the Rust "meta"
|
||||
//! annotations on structs, enums, enum variants and fields.
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use quote::{quote, quote_spanned};
|
||||
use syn::{spanned::Spanned, *};
|
||||
|
|
@ -62,22 +60,6 @@ pub(crate) enum NameRef {
|
|||
Path(Path),
|
||||
}
|
||||
|
||||
impl NameRef {
|
||||
/// Access a representation of the XML name as str.
|
||||
///
|
||||
/// If this name reference is a [`Self::Path`], this will return the name
|
||||
/// of the rightmost identifier in the path.
|
||||
///
|
||||
/// If this name reference is a [`Self::Literal`], this will return the
|
||||
/// contents of the literal.
|
||||
pub(crate) fn repr_to_string(&self) -> Cow<'_, str> {
|
||||
match self {
|
||||
Self::Literal { ref value, .. } => Cow::Borrowed(value.as_str()),
|
||||
Self::Path(ref path) => path.segments.last().unwrap().ident.to_string().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl syn::parse::Parse for NameRef {
|
||||
fn parse(input: syn::parse::ParseStream<'_>) -> Result<Self> {
|
||||
if input.peek(syn::LitStr) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue