ton_macros 0.2.2

A collection of types and utilities for interacting with the TON network
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use proc_macro_crate::{FoundCrate, crate_name};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};

pub(crate) fn crate_name_or_panic(orig_name: &'static str) -> TokenStream {
    let Ok(ton_crate) = crate_name(orig_name) else {
        panic!("Can't find {orig_name} crate");
    };

    match ton_crate {
        FoundCrate::Itself => quote::quote! { crate },
        FoundCrate::Name(name) => {
            let ident = format_ident!("{name}");
            quote! { #ident }
        },
    }
}