pub fn import_tokens_internal<T: Into<TokenStream>>(
    tokens: T
) -> Result<TokenStream>
Expand description

The internal implementation for the import_tokens macro.

You can call this in your own proc macros to make use of the import_tokens functionality directly, though this approach is limited. The arguments should be a TokenStream2 that can parse into an ImportTokensArgs successfully. That is a valid let variable declaration set to equal a path where an #[export_tokens] with the specified ident can be found.

Example:

use macro_magic_core::*;
use quote::quote;

let some_ident = quote!(my_tokens);
let some_path = quote!(other_crate::exported_item);
let tokens = import_tokens_internal(quote!(let #some_ident = other_crate::ExportedItem)).unwrap();
assert_eq!(
    tokens.to_string(),
    "other_crate :: __export_tokens_tt_exported_item ! { my_tokens , \
    :: macro_magic :: __private :: import_tokens_inner }");

If these tokens were emitted as part of a proc macro, they would expand to a variable declaration like:

let my_tokens: TokenStream2;

where my_tokens contains the tokens of ExportedItem.