pub struct SingleFileGenerator {
pub sort_items: bool,
}Expand description
Generator that outputs all code into a single file.
This is the simplest generator strategy: all modules become nested mod {} blocks
in a single lib.rs (or main.rs for binaries).
§Example
ⓘ
use ryo_source::generator::{ModuleTree, SingleFileGenerator};
let tree = ModuleTree::crate_root()
.with_item(PureItem::Struct(config_struct))
.with_child(
ModuleTree::new("utils")
.with_vis(PureVis::Public)
.with_item(PureItem::Fn(helper_fn))
);
let generator = SingleFileGenerator::new();
let result = generator.generate(&tree).unwrap();
// result.source contains:
// struct Config { ... }
// pub mod utils {
// fn helper() { ... }
// }Fields§
§sort_items: boolWhether to sort items within each module.
Implementations§
Source§impl SingleFileGenerator
impl SingleFileGenerator
Sourcepub fn with_sort_items(self, sort: bool) -> Self
pub fn with_sort_items(self, sort: bool) -> Self
Enable or disable item sorting within modules.
When enabled, items are sorted by kind (uses, then types, then functions) and then alphabetically by name.
Trait Implementations§
Source§impl Clone for SingleFileGenerator
impl Clone for SingleFileGenerator
Source§fn clone(&self) -> SingleFileGenerator
fn clone(&self) -> SingleFileGenerator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SingleFileGenerator
impl Debug for SingleFileGenerator
Source§impl Default for SingleFileGenerator
impl Default for SingleFileGenerator
Source§fn default() -> SingleFileGenerator
fn default() -> SingleFileGenerator
Returns the “default value” for a type. Read more
Source§impl SourceGenerator for SingleFileGenerator
impl SourceGenerator for SingleFileGenerator
Source§fn generate(&self, tree: &ModuleTree) -> Result<GeneratedSource, ToSynError>
fn generate(&self, tree: &ModuleTree) -> Result<GeneratedSource, ToSynError>
Generate source code from a module tree.
Auto Trait Implementations§
impl Freeze for SingleFileGenerator
impl RefUnwindSafe for SingleFileGenerator
impl Send for SingleFileGenerator
impl Sync for SingleFileGenerator
impl Unpin for SingleFileGenerator
impl UnsafeUnpin for SingleFileGenerator
impl UnwindSafe for SingleFileGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more