mockiato-codegen 0.9.6

Internally used by mockiato for code generation. This crate should never be used directly
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use proc_macro2::Span;
use syn::{parse_quote, Attribute, GenericParam, Ident, Lifetime, LifetimeDef, LitStr};

pub(super) fn doc_attribute(content: String) -> Attribute {
    let string_literal = LitStr::new(&content, Span::call_site());

    parse_quote! {
        #[doc = #string_literal]
    }
}

pub(super) fn ident_to_string_literal(ident: &Ident) -> LitStr {
    LitStr::new(&ident.to_string(), ident.span())
}

pub(super) fn lifetime_to_generic_param(lifetime: Lifetime) -> GenericParam {
    GenericParam::Lifetime(LifetimeDef::new(lifetime))
}