bluejay-typegen-codegen 0.4.0

Code generation utilities for `bluejay-typegen-macro`
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use syn::parse_quote;

pub(crate) fn option(ty: syn::Type) -> syn::Type {
    parse_quote! { ::std::option::Option<#ty> }
}

pub(crate) fn vec(ty: syn::Type) -> syn::Type {
    parse_quote! { ::std::vec::Vec<#ty> }
}

pub(crate) fn string(borrows: bool) -> syn::Type {
    if borrows {
        parse_quote! { ::std::borrow::Cow<'a, str> }
    } else {
        parse_quote! { ::std::string::String }
    }
}