Skip to main content

ModuleInliner

Struct ModuleInliner 

Source
pub struct ModuleInliner {
    path: PathBuf,
    io_errs: IoErrs,
    parse_errs: ParseErrs,
}

Fields§

§path: PathBuf§io_errs: IoErrs§parse_errs: ParseErrs

Implementations§

Source§

impl ModuleInliner

Source

pub fn new(root: impl AsRef<Path>) -> Self

Creates a new ModuleInliner

Source

pub fn fork(&self, path: impl AsRef<Path>) -> Self

Source

pub fn join(&mut self, other: ModuleInliner) -> &mut Self

Source

pub fn main_path(&self) -> PathBuf

Source

pub fn fallback_path(&self) -> Option<PathBuf>

Source

pub fn has_errors(&self) -> bool

Returns true when the ModuleInliner has errors to report

Source

pub fn into_errs(self) -> Option<(IoErrs, ParseErrs)>

Returns the IO Errors and parse Errors

Source

pub fn inline(self, expr: Expr) -> Result<Expr, (Expr, IoErrs, ParseErrs)>

Traverses an Expr, attempting to inline all submodules.

This is a simple wrapper around ModuleInliner::fold_expr() and ModuleInliner::into_errs()

Source

fn handle_io_error<T>(&mut self, path: PathBuf, error: Error) -> Option<T>

Records an I/O error for later

Source

fn handle_parse_error<T>( &mut self, path: PathBuf, error: ParseError, ) -> Option<T>

Records a ParseError for later

Source§

impl ModuleInliner

Source

fn inline_file(&mut self) -> Option<Result<At<Expr>, Infallible>>

Source

fn inline_file_at(&mut self, path: &str) -> Option<Result<At<Expr>, Infallible>>

Inlines a file at the given path,

Trait Implementations§

Source§

impl Fold<DefaultTypes> for ModuleInliner

Source§

fn fold_bind( &mut self, bind: Bind<DefaultTypes>, ) -> Result<Bind<DefaultTypes>, Self::Error>

Traverses down the module tree, entering ever nested directories

Source§

type Error = Infallible

Source§

fn fold_annotation(&mut self, span: Span) -> Result<Span, Self::Error>

Consumes an Annotation in A, possibly transforms it, and produces a replacement Annotation in B
Source§

fn fold_macro_id(&mut self, name: Symbol) -> Result<Symbol, Self::Error>

Consumes a MacroId in A, possibly transforms it, and produces a replacement MacroId in B
Source§

fn fold_symbol(&mut self, name: Symbol) -> Result<Symbol, Self::Error>

Consumes a Symbol in A, possibly transforms it, and produces a replacement Symbol in B
Source§

fn fold_path(&mut self, path: AstPath) -> Result<AstPath, Self::Error>

Consumes a Path in A, possibly transforms it, and produces a replacement Path in B
Source§

fn fold_literal(&mut self, lit: Literal) -> Result<Literal, Self::Error>

Consumes a Literal in A, possibly transforms it, and produces a replacement Literal in B
Source§

fn fold_at_expr( &mut self, expr: At<Expr<From>, From>, ) -> Result<At<Expr<To>, To>, Self::Error>

Folds an annotated expression, so the expression and annotation can be seen at once.
Source§

fn fold_expr(&mut self, expr: Expr<From>) -> Result<Expr<To>, Self::Error>

Consumes an Expr, possibly transforms it, and produces a replacement Expr
Source§

fn fold_use(&mut self, item: Use<From>) -> Result<Use<To>, Self::Error>

Consumes a Use, possibly transforms it, and produces a replacement Use
Source§

fn fold_pat(&mut self, pat: Pat<From>) -> Result<Pat<To>, Self::Error>

Consumes a Pat, possibly transforms it, and produces a replacement Pat
Source§

fn fold_make(&mut self, make: Make<From>) -> Result<Make<To>, Self::Error>

Consumes a Make, possibly transforms it, and produces a replacement Make
Source§

fn fold_makearm( &mut self, arm: MakeArm<From>, ) -> Result<MakeArm<To>, Self::Error>

Consumes a MakeArm, possibly transforms it, and produces a replacement MakeArm
Source§

fn fold_match(&mut self, mtch: Match<From>) -> Result<Match<To>, Self::Error>

Consumes a Make, possibly transforms it, and produces a replacement Make
Source§

fn fold_matcharm( &mut self, arm: MatchArm<From>, ) -> Result<MatchArm<To>, Self::Error>

Consumes a MakeArm, possibly transforms it, and produces a replacement MakeArm

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.