BorrowGraph

Struct BorrowGraph 

Source
pub struct BorrowGraph<Loc: Copy, Lbl: Clone + Ord>(/* private fields */);

Implementations§

Source§

impl<Loc: Copy, Lbl: Clone + Ord> BorrowGraph<Loc, Lbl>

Source

pub fn new() -> Self

creates an empty borrow graph

Source

pub fn is_mutable(&self, id: RefID) -> bool

checks if the given reference is mutable or not

Source

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

Source

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

Source

pub fn between_edges( &self, parent: RefID, child: RefID, ) -> Vec<(Loc, Vec<Lbl>, bool)>

Return the edges between parent and child

Source

pub fn out_edges(&self, id: RefID) -> Vec<(Loc, Vec<Lbl>, bool, RefID)>

Return the outgoing edges from id

Source

pub fn in_edges(&self, id: RefID) -> Vec<(Loc, RefID, Vec<Lbl>, bool)>

Return the incoming edges into id

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn leq(&self, other: &Self) -> bool

checks if self covers other

Source

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

Source

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.

Source

pub fn contains_id(&self, ref_id: RefID) -> bool

Checks if the current reference is in the graph

Source

pub fn all_refs(&self) -> BTreeSet<RefID>

Returns all ref ids in the map

Source

pub fn display(&self)
where Lbl: Display,

Prints out a view of the borrow graph

Trait Implementations§

Source§

impl<Loc: Clone + Copy, Lbl: Clone + Clone + Ord> Clone for BorrowGraph<Loc, Lbl>

Source§

fn clone(&self) -> BorrowGraph<Loc, Lbl>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Loc: Debug + Copy, Lbl: Debug + Clone + Ord> Debug for BorrowGraph<Loc, Lbl>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Loc: Default + Copy, Lbl: Default + Clone + Ord> Default for BorrowGraph<Loc, Lbl>

Source§

fn default() -> BorrowGraph<Loc, Lbl>

Returns the “default value” for a type. Read more
Source§

impl<Loc: PartialEq + Copy, Lbl: PartialEq + Clone + Ord> PartialEq for BorrowGraph<Loc, Lbl>

Source§

fn eq(&self, other: &BorrowGraph<Loc, Lbl>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Loc: Copy, Lbl: Clone + Ord> StructuralPartialEq for BorrowGraph<Loc, Lbl>

Auto Trait Implementations§

§

impl<Loc, Lbl> Freeze for BorrowGraph<Loc, Lbl>

§

impl<Loc, Lbl> RefUnwindSafe for BorrowGraph<Loc, Lbl>
where Loc: RefUnwindSafe, Lbl: RefUnwindSafe,

§

impl<Loc, Lbl> Send for BorrowGraph<Loc, Lbl>
where Loc: Send, Lbl: Send,

§

impl<Loc, Lbl> Sync for BorrowGraph<Loc, Lbl>
where Loc: Sync, Lbl: Sync,

§

impl<Loc, Lbl> Unpin for BorrowGraph<Loc, Lbl>

§

impl<Loc, Lbl> UnwindSafe for BorrowGraph<Loc, Lbl>
where Loc: RefUnwindSafe, Lbl: RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.