Skip to main content

UnitSources

Trait UnitSources 

Source
pub trait UnitSources {
    // Required method
    fn source_of(&self, path: &Path) -> Option<&str>;
}
Expand description

Where the text of a unit’s files comes from — everything a one-walk cook needs from the world.

A trait rather than a path→text map because the caller decides where text comes from: a disk provider, the buffers an editor holds, a test’s fixtures. None is an answer too, and a load-bearing one — the unit’s cook records the hole (RenderedUnit::missing) rather than cooking an empty file, because “this file is empty” and “this file was not read” are different programs.

Required Methods§

Source

fn source_of(&self, path: &Path) -> Option<&str>

The text of path, when this caller has it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<S> UnitSources for HashMap<PathBuf, S>
where S: Borrow<str>,

Any map from a path to its text is a source of texts — the shape every caller already has.

Source§

fn source_of(&self, path: &Path) -> Option<&str>

Implementors§