pub fn generate(
tokens: TokenStream,
crate_name: &str,
) -> Result<(TokenStream, Vec<(u8, 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
Vec<(u8, String)>of(char_byte, replacement)pairs, sorted bychar_byteascending. Callers can derive convenience strings (such as the concatenation of all source bytes or replacements) from this list as needed.
§Errors
Returns a syn::Error if the token stream cannot be parsed or if the character
mappings are invalid.