pub struct PureFile {
pub attrs: Vec<PureAttribute>,
pub items: Vec<PureItem>,
}Expand description
A complete Rust source file (pure, no spans).
Fields§
§attrs: Vec<PureAttribute>Attributes on the file (e.g., #![allow(...)]).
items: Vec<PureItem>Items in the file.
Implementations§
Source§impl PureFile
impl PureFile
Sourcepub fn from_source(source: &str) -> SourceResult<Self>
pub fn from_source(source: &str) -> SourceResult<Self>
Parse source code directly into PureFile.
Source§impl PureFile
impl PureFile
Sourcepub fn to_syn_file(&self) -> Result<File, ToSynError>
pub fn to_syn_file(&self) -> Result<File, ToSynError>
Convert to syn::File for code generation.
Sourcepub fn to_source(&self) -> Result<String, ToSynError>
pub fn to_source(&self) -> Result<String, ToSynError>
Generate source code string.
Returns formatted source code using prettyplease. Falls back to quote-based stringification if prettyplease panics.
Note: This method does NOT run rustfmt. For final output, use
format_files_with_rustfmt() to batch-format written files.
PureItem::Verbatim handling:
Each Verbatim at the top of self.items is staged out of the way
before lowering to syn::File by substituting a unique sentinel stub
fn __ryo_verbatim_{N}() {}. After prettyplease produces formatted
source for the rest of the file, the line containing each sentinel is
replaced with the raw bytes carried by the corresponding Verbatim.
This is the only path in ryo that preserves arbitrary raw source text
(DSL macro spacing, // line comments, blank lines, etc.) end-to-end
through the codegen pipeline.