Skip to main content

ModuleSource

Struct ModuleSource 

Source
pub struct ModuleSource<'a> {
    pub name: String,
    pub file: &'a File,
    pub imports: HashMap<String, ImportTarget>,
    pub text: Option<&'a str>,
    pub package: Option<u32>,
    pub importable: Vec<(String, usize)>,
}
Expand description

A source module: a parsed file, its label, and what its imports name.

Fields§

§name: String

A label for the module. Messages print an import as written, so the label is never a lookup key.

§file: &'a File§imports: HashMap<String, ImportTarget>

What each import names, by its first segment. An import missing here is “cannot find module”.

§text: Option<&'a str>

The module’s source text, for fixes placed by lines (spec docs/superpowers/specs/2026-10-10-phase-3-4b-fixes-and-colour-design.md §4.7). None in the resolver’s own tests.

§package: Option<u32>

A key equal for two modules of one package; None for a loose program, whose files count as one package (spec 3.4b §4.6).

§importable: Vec<(String, usize)>

Every loaded module this one could import: the name an import of it writes, and its index in modules (spec 3.4b §4.6).

Implementations§

Source§

impl<'a> ModuleSource<'a>

Source

pub fn new(name: impl Into<String>, file: &'a File) -> Self

A module with an empty import table; name_imports fills it by name.

Auto Trait Implementations§

§

impl<'a> Freeze for ModuleSource<'a>

§

impl<'a> RefUnwindSafe for ModuleSource<'a>

§

impl<'a> Send for ModuleSource<'a>

§

impl<'a> Sync for ModuleSource<'a>

§

impl<'a> Unpin for ModuleSource<'a>

§

impl<'a> UnsafeUnpin for ModuleSource<'a>

§

impl<'a> UnwindSafe for ModuleSource<'a>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.