Struct Loader

Source
pub struct Loader<S, P, R> { /* private fields */ }
Expand description

Combined file loader, lexer, and parser for multiple modules.

Implementations§

Source§

impl<'s, P: Default> Loader<&'s str, P, fn(Import<'_, &str, P>) -> Result<File<String, P>, String>>

Source

pub fn new(prelude: impl IntoIterator<Item = Def<&'s str>>) -> Self

Initialise the loader with prelude definitions.

The prelude is a special module that is implicitly included by all other modules (including the main module). That means that all filters defined in the prelude can be called from any module.

The prelude is normally initialised with filters like map or true.

Source§

impl<S, P, R> Loader<S, P, R>

Source

pub fn with_read<R2>(self, read: R2) -> Loader<S, P, R2>

Provide a function to return the contents of included/imported module files.

For every included/imported module, the loader will call this function to obtain the contents of the module. For example, if we have include "foo", the loader calls read("foo").

Source§

impl<S, R> Loader<S, PathBuf, R>

Source

pub fn with_std_read( self, paths: &[PathBuf], ) -> Loader<S, PathBuf, impl FnMut(Import<'_, &str, PathBuf>) -> Result<File<String, PathBuf>, String> + '_>

Read the contents of included/imported module files by performing file I/O.

Source§

impl<'s, P: Clone + Eq, R: FnMut(Import<'_, &'s str, P>) -> Result<File<String, P>, String>> Loader<&'s str, P, R>

Source

pub fn load( self, arena: &'s Arena, file: File<&'s str, P>, ) -> Result<Modules<&'s str, P>, Errors<&'s str, P>>

Load a set of modules, starting from a given file.

Auto Trait Implementations§

§

impl<S, P, R> Freeze for Loader<S, P, R>
where R: Freeze,

§

impl<S, P, R> RefUnwindSafe for Loader<S, P, R>

§

impl<S, P, R> Send for Loader<S, P, R>
where R: Send, P: Send, S: Send,

§

impl<S, P, R> Sync for Loader<S, P, R>
where R: Sync, P: Sync, S: Sync,

§

impl<S, P, R> Unpin for Loader<S, P, R>
where R: Unpin, P: Unpin, S: Unpin,

§

impl<S, P, R> UnwindSafe for Loader<S, P, R>
where R: UnwindSafe, P: UnwindSafe, S: UnwindSafe,

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.