Skip to main content

parse_source

Function parse_source 

Source
pub fn parse_source(source: &str, path: &str) -> Result<ParsedFile, String>
Expand description

Parses Rust source code from a string into a ParsedFile.

This is the primary entry point for programmatic usage and testing. The path parameter is used only for error messages and the ParsedFile::path field — it doesn’t need to be a real file.

§Errors

Returns an error string if syn::parse_file fails (e.g., invalid Rust syntax).