Trait trustfall_core::interpreter::AsVertex
source · pub trait AsVertex<V>: Debug + Clone {
// Required methods
fn as_vertex(&self) -> Option<&V>;
fn into_vertex(self) -> Option<V>;
}
Expand description
Attempt to dereference a value to a &V
, returning None
if the value did not contain a V
.
This trait allows types that may contain a V
to be projected down to a Option<&V>
.
It’s similar in spirit to the built-in Deref
trait.
The primary difference is that AsVertex
does not guarantee it’ll be able to produce a &V
,
instead returning Option<&V>
. The same type may implement AsVertex<V>
multiple times
with different V
types, also unlike Deref
.
Required Methods§
sourcefn as_vertex(&self) -> Option<&V>
fn as_vertex(&self) -> Option<&V>
Dereference this value into a &V
, if the value happens to contain a V
.
If this method returns Some(&v)
, AsVertex::into_vertex()
for the same V
is guaranteed to return Some(v)
as well.
sourcefn into_vertex(self) -> Option<V>
fn into_vertex(self) -> Option<V>
Consume self
and produce the contained V
, if one was indeed present.
If this method returned Some(v)
, prior AsVertex::as_vertex()
calls for the same V
are guaranteed to have returned Some(&v)
as well.