pub struct TransitiveRelation<T: Clone + Debug + Eq + Hash> { /* fields omitted */ }
Applies the (partial) function to each edge and returns a new
relation. If f
returns None
for any end-point, returns
None
.
Indicate that a < b
(where <
is this relation)
Check whether a < target
(transitively)
Thinking of x R y
as an edge x -> y
in a graph, this
returns all things reachable from a
.
Really this probably ought to be impl Iterator<Item=&T>
, but
I'm too lazy to make that work, and -- given the caching
strategy -- it'd be a touch tricky anyhow.
pub fn postdom_upper_bound(&self, a: &T, b: &T) -> Option<&T> | [src] |
Picks what I am referring to as the "postdominating"
upper-bound for a
and b
. This is usually the least upper
bound, but in cases where there is no single least upper
bound, it is the "mutual immediate postdominator", if you
imagine a graph where a < b
means a -> b
.
This function is needed because region inference currently
requires that we produce a single "UB", and there is no best
choice for the LUB. Rather than pick arbitrarily, I pick a
less good, but predictable choice. This should help ensure
that region inference yields predictable results (though it
itself is not fully sufficient).
Examples are probably clearer than any prose I could write
(there are corresponding tests below, btw). In each case,
the query is postdom_upper_bound(a, b)
:
// returns Some(x), which is also LUB
a -> a1 -> x
^
|
b -> b1 ---+
// returns Some(x), which is not LUB (there is none)
// diagonal edges run left-to-right
a -> a1 -> x
\/ ^
/\ |
b -> b1 ---+
// returns None
a -> a1
b -> b1
Viewing the relation as a graph, computes the "mutual
immediate postdominator" of a set of points (if one
exists). See postdom_upper_bound
for details.
Returns the set of bounds X
such that:
a < X
and b < X
- there is no
Y != X
such that a < Y
and Y < X
- except for the case where
X < a
(i.e., a strongly connected
component in the graph). In that case, the smallest
representative of the SCC is returned (as determined by the
internal indices).
Note that this set can, in principle, have any size.
Given an element A, returns the maximal set {B} of elements B
such that
- A != B
- A R B is true
- for each i, j: B[i] R B[j] does not hold
The intuition is that this moves "one step up" through a lattice
(where the relation is encoding the <=
relation for the lattice).
So e.g., if the relation is ->
and we have
a -> b -> d -> f
| ^
+--> c -> e ---+
then parents(a)
returns [b, c]
. The postdom_parent
function
would further reduce this to just f
.
pub fn postdom_parent(&self, a: &T) -> Option<&T> | [src] |
A "best" parent in some sense. See parents
and
postdom_upper_bound
for more details.
Returns the "default value" for a type. Read more
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S
is the encoder/decoder state type, T
is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more