types.rs

 1// Copyright (c) 2024 Jonas Schäfer <jonas@zombofant.net>
 2//
 3// This Source Code Form is subject to the terms of the Mozilla Public
 4// License, v. 2.0. If a copy of the MPL was not distributed with this
 5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
 6
 7//! Module with specific [`syn::Type`] constructors.
 8
 9use proc_macro2::Span;
10use syn::*;
11
12/// Construct a [`syn::Type`] referring to `::xso::exports::rxml::QName`.
13pub(crate) fn qname_ty(span: Span) -> Type {
14    Type::Path(TypePath {
15        qself: None,
16        path: Path {
17            leading_colon: Some(syn::token::PathSep {
18                spans: [span, span],
19            }),
20            segments: [
21                PathSegment {
22                    ident: Ident::new("xso", span),
23                    arguments: PathArguments::None,
24                },
25                PathSegment {
26                    ident: Ident::new("exports", span),
27                    arguments: PathArguments::None,
28                },
29                PathSegment {
30                    ident: Ident::new("rxml", span),
31                    arguments: PathArguments::None,
32                },
33                PathSegment {
34                    ident: Ident::new("QName", span),
35                    arguments: PathArguments::None,
36                },
37            ]
38            .into_iter()
39            .collect(),
40        },
41    })
42}