bevy_macro_utils

Module fq_std

Source
Expand description

This module contains unit structs that should be used inside quote! and spanned_quote! using the variable interpolation syntax in place of their equivalent structs and traits present in std.

To create hygienic proc macros, all the names must be its fully qualified form. These unit structs help us to not specify the fully qualified name every single time.

§Example

Instead of writing this:

quote!(
    fn get_id() -> Option<i32> {
        Some(0)
    }
);

Or this:

quote!(
    fn get_id() -> ::core::option::Option<i32> {
        ::core::option::Option::Some(0)
    }
);

We should write this:

use bevy_macro_utils::fq_std::FQOption;

quote!(
    fn get_id() -> #FQOption<i32> {
        #FQOption::Some(0)
    }
);

Structs§