pub struct BorrowGraph<Loc: Copy, Lbl: Clone + Ord>(_);

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 copy 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<BorrowGraph<Loc, Lbl>> for BorrowGraph<Loc, Lbl>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

source§

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

source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.