pub fn generate(
tokens: TokenStream,
crate_name: &str,
) -> Result<(TokenStream, (String, String))>Expand description
Generate escape functions from a token stream template
This function takes a token stream representing character mappings and generates the corresponding escape function implementations. It returns both the generated code and metadata about the escape mappings.
§Arguments
tokens- A token stream containing the character mappings in the formatnew!(char -> "escape", ...)crate_name- The name of the crate where the generated code will be used
§Returns
Returns a tuple containing:
- The generated code as a
TokenStream - A tuple of
(escapes, escaped)whereescapesis a string of characters to escape andescapedis the concatenated escape sequences
§Errors
Returns a syn::Error if the token stream cannot be parsed or if the character
mappings are invalid.