Struct borrow_graph::graph::BorrowGraph
source · pub struct BorrowGraph<Loc: Copy, Lbl: Clone + Ord>(_);
Implementations§
source§impl<Loc: Copy, Lbl: Clone + Ord> BorrowGraph<Loc, Lbl>
impl<Loc: Copy, Lbl: Clone + Ord> BorrowGraph<Loc, Lbl>
sourcepub fn is_mutable(&self, id: RefID) -> bool
pub fn is_mutable(&self, id: RefID) -> bool
checks if the given reference is mutable or not
sourcepub fn new_ref(&mut self, id: RefID, mutable: bool)
pub fn new_ref(&mut self, id: RefID, mutable: bool)
Adds a new reference to the borrow graph Fails if the id is already in use
sourcepub fn borrowed_by(
&self,
id: RefID
) -> (BTreeMap<RefID, Loc>, BTreeMap<Lbl, BTreeMap<RefID, Loc>>)
pub fn borrowed_by( &self, id: RefID ) -> (BTreeMap<RefID, Loc>, BTreeMap<Lbl, BTreeMap<RefID, Loc>>)
Return the references borrowing the id
reference
The borrows are collected by first label in the borrow edge
BTreeMap<RefID, Loc>
represents all of the “full” or “epsilon” borrows (non field borrows)
BTreeMap<Lbl, BTreeMap<RefID, Loc>>)
represents the field borrows, collected over the
first label
sourcepub fn between_edges(
&self,
parent: RefID,
child: RefID
) -> Vec<(Loc, Vec<Lbl>, bool)>
pub fn between_edges( &self, parent: RefID, child: RefID ) -> Vec<(Loc, Vec<Lbl>, bool)>
Return the edges between parent and child
sourcepub fn out_edges(&self, id: RefID) -> Vec<(Loc, Vec<Lbl>, bool, RefID)>
pub fn out_edges(&self, id: RefID) -> Vec<(Loc, Vec<Lbl>, bool, RefID)>
Return the outgoing edges from id
sourcepub fn in_edges(&self, id: RefID) -> Vec<(Loc, RefID, Vec<Lbl>, bool)>
pub fn in_edges(&self, id: RefID) -> Vec<(Loc, RefID, Vec<Lbl>, bool)>
Return the incoming edges into id
sourcepub fn add_strong_borrow(&mut self, loc: Loc, parent_id: RefID, child_id: RefID)
pub fn add_strong_borrow(&mut self, loc: Loc, parent_id: RefID, child_id: RefID)
Add a strong (exact) epsilon borrow from parent_id
to child_id
sourcepub fn add_strong_field_borrow(
&mut self,
loc: Loc,
parent_id: RefID,
field: Lbl,
child_id: RefID
)
pub fn add_strong_field_borrow( &mut self, loc: Loc, parent_id: RefID, field: Lbl, child_id: RefID )
Add a strong (exact) field borrow from parent_id
to child_id
at field field
sourcepub fn add_weak_borrow(&mut self, loc: Loc, parent_id: RefID, child_id: RefID)
pub fn add_weak_borrow(&mut self, loc: Loc, parent_id: RefID, child_id: RefID)
Add a weak (prefix) epsilon borrow from parent_id
to child_id
i.e. child_id
might be borrowing from ANY field in parent_id
sourcepub fn add_weak_field_borrow(
&mut self,
loc: Loc,
parent_id: RefID,
field: Lbl,
child_id: RefID
)
pub fn add_weak_field_borrow( &mut self, loc: Loc, parent_id: RefID, field: Lbl, child_id: RefID )
Add a weak (prefix) field borrow from parent_id
to child_id
at field field
i.e. child_id
might be borrowing from ANY field in parent_id
rooted at field
sourcepub fn release(&mut self, id: RefID)
pub fn release(&mut self, id: RefID)
Remove reference id
from the graph
Fixes any transitive borrows, so if parent
borrowed by id
borrowed by child
After the release, parent
borrowed by child
sourcepub fn remap_refs(&mut self, id_map: &BTreeMap<RefID, RefID>)
pub fn remap_refs(&mut self, id_map: &BTreeMap<RefID, RefID>)
Utility for remapping the reference ids according the id_map
provided
If it is not in the map, the id remains the same
sourcepub fn join(&self, other: &Self) -> Self
pub fn join(&self, other: &Self) -> Self
Joins other into self It adds only ‘unmatched’ edges from other into self, i.e. for any edge in other, if there is an edge in self that is <= than that edge, it is not added.
sourcepub fn contains_id(&self, ref_id: RefID) -> bool
pub fn contains_id(&self, ref_id: RefID) -> bool
Checks if the current reference is in the graph
Trait Implementations§
source§impl<Loc: Clone + Copy, Lbl: Clone + Clone + Ord> Clone for BorrowGraph<Loc, Lbl>
impl<Loc: Clone + Copy, Lbl: Clone + Clone + Ord> Clone for BorrowGraph<Loc, Lbl>
source§fn clone(&self) -> BorrowGraph<Loc, Lbl>
fn clone(&self) -> BorrowGraph<Loc, Lbl>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Loc: Default + Copy, Lbl: Default + Clone + Ord> Default for BorrowGraph<Loc, Lbl>
impl<Loc: Default + Copy, Lbl: Default + Clone + Ord> Default for BorrowGraph<Loc, Lbl>
source§fn default() -> BorrowGraph<Loc, Lbl>
fn default() -> BorrowGraph<Loc, Lbl>
source§impl<Loc: PartialEq + Copy, Lbl: PartialEq + Clone + Ord> PartialEq<BorrowGraph<Loc, Lbl>> for BorrowGraph<Loc, Lbl>
impl<Loc: PartialEq + Copy, Lbl: PartialEq + Clone + Ord> PartialEq<BorrowGraph<Loc, Lbl>> for BorrowGraph<Loc, Lbl>
source§fn eq(&self, other: &BorrowGraph<Loc, Lbl>) -> bool
fn eq(&self, other: &BorrowGraph<Loc, Lbl>) -> bool
self
and other
values to be equal, and is used
by ==
.