pub struct ModuleGraph { /* private fields */ }Expand description
Canonical module graph — the single source of truth for import resolution.
Built before compilation; modules compile in topo_order so that
dependencies are always available when a module is compiled.
Implementations§
Source§impl ModuleGraph
impl ModuleGraph
Sourcepub fn new(
nodes: Vec<ModuleNode>,
path_to_id: HashMap<String, ModuleId>,
topo_order: Vec<ModuleId>,
root_id: ModuleId,
) -> Self
pub fn new( nodes: Vec<ModuleNode>, path_to_id: HashMap<String, ModuleId>, topo_order: Vec<ModuleId>, root_id: ModuleId, ) -> Self
Create a new graph from pre-built components.
Used by the graph builder after all nodes, interfaces, and edges have been constructed and topologically sorted.
Sourcepub fn id_for_path(&self, path: &str) -> Option<ModuleId>
pub fn id_for_path(&self, path: &str) -> Option<ModuleId>
Look up a module by its canonical path.
Sourcepub fn node(&self, id: ModuleId) -> &ModuleNode
pub fn node(&self, id: ModuleId) -> &ModuleNode
Get a module node by id.
Sourcepub fn node_mut(&mut self, id: ModuleId) -> &mut ModuleNode
pub fn node_mut(&mut self, id: ModuleId) -> &mut ModuleNode
Get a mutable module node by id.
Sourcepub fn topo_order(&self) -> &[ModuleId]
pub fn topo_order(&self) -> &[ModuleId]
Topological compilation order (dependencies before dependents). Does NOT include the root module — that is compiled separately.
Sourcepub fn nodes(&self) -> &[ModuleNode]
pub fn nodes(&self) -> &[ModuleNode]
All nodes in the graph.
Trait Implementations§
Source§impl Clone for ModuleGraph
impl Clone for ModuleGraph
Source§fn clone(&self) -> ModuleGraph
fn clone(&self) -> ModuleGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModuleGraph
impl RefUnwindSafe for ModuleGraph
impl Send for ModuleGraph
impl Sync for ModuleGraph
impl Unpin for ModuleGraph
impl UnsafeUnpin for ModuleGraph
impl UnwindSafe for ModuleGraph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more