pub struct Hiding<N> { /* private fields */ }
Expand description
Wrapper that allows a node to be “hidden” during program construction.
§Program construction
When a program is constructed in post-order, the parent node is created based on its children. We use this fact to introduce special branching logic:
- A
case
node with a left “hidden” child and a right non-hidden child becomesassertr
. - A
case
node with a left non-hidden child and a right “hidden” child becomesassertl
. - Otherwise, any node with “hidden” children becomes itself “hidden” with an updated CMR.
- Any node with non-hidden children remains unchanged.
The program can be extracted from the wrapper when construction is finished. The program is invalid if the root node is “hidden”.
§Wrapping
A node can be wrapped via Hiding::from
to add hiding support.
A wrapped node can be converted into a “hidden” node via Hiding::hide
.
Finally, a “hidden” node can be manually created via Hiding::hidden
.
§Virtual hidden nodes
The wrapper merely simulates hidden nodes. At no point are actual hidden nodes created. To stress this fact, I write “hidden” in quotation marks.
Implementations§
Source§impl<N> Hiding<N>
impl<N> Hiding<N>
Trait Implementations§
Source§impl<N: CoreConstructible + HasCmr> CoreConstructible for Hiding<N>
impl<N: CoreConstructible + HasCmr> CoreConstructible for Hiding<N>
fn iden(inference_context: &Context) -> Self
fn unit(inference_context: &Context) -> Self
fn injl(child: &Self) -> Self
fn injr(child: &Self) -> Self
fn take(child: &Self) -> Self
fn drop_(child: &Self) -> Self
fn comp(left: &Self, right: &Self) -> Result<Self, Error>
fn case(left: &Self, right: &Self) -> Result<Self, Error>
fn assertl(left: &Self, right: Cmr) -> Result<Self, Error>
fn assertr(left: Cmr, right: &Self) -> Result<Self, Error>
fn pair(left: &Self, right: &Self) -> Result<Self, Error>
fn fail(inference_context: &Context, entropy: FailEntropy) -> Self
fn const_word(inference_context: &Context, word: Word) -> Self
Source§fn inference_context(&self) -> &Context
fn inference_context(&self) -> &Context
Accessor for the type inference context used to create the object.
Source§fn scribe(ctx: &Context, value: &Value) -> Self
fn scribe(ctx: &Context, value: &Value) -> Self
Create an expression that produces the given
value
. Read moreSource§fn bit_false(inference_context: &Context) -> Self
fn bit_false(inference_context: &Context) -> Self
Create a DAG that takes any input and returns bit
0
as constant output. Read moreSource§fn bit_true(inference_context: &Context) -> Self
fn bit_true(inference_context: &Context) -> Self
Create a DAG that takes any input and returns bit
1
as constant output. Read moreSource§fn cond(left: &Self, right: &Self) -> Result<Self, Error>
fn cond(left: &Self, right: &Self) -> Result<Self, Error>
Create a DAG that takes a bit and an input,
such that the
left
child is evaluated on the input if the bit is 1
(if branch)
and the right
child is evaluated on the input otherwise (else branch). Read moreSource§fn assert(child: &Self, hash: Cmr) -> Result<Self, Error>
fn assert(child: &Self, hash: Cmr) -> Result<Self, Error>
Create a DAG that asserts that its child returns
true
, and fails otherwise.
The hash
identifies the assertion and is returned upon failure. Read moreSource§fn not(child: &Self) -> Result<Self, Error>
fn not(child: &Self) -> Result<Self, Error>
Create a DAG that computes Boolean NOT of the
child
. Read moreSource§impl<X, N> DisconnectConstructible<Option<X>> for Hiding<N>
impl<X, N> DisconnectConstructible<Option<X>> for Hiding<N>
Source§impl<N: CoreConstructible> From<N> for Hiding<N>
impl<N: CoreConstructible> From<N> for Hiding<N>
Source§impl<J, N> JetConstructible<J> for Hiding<N>where
N: JetConstructible<J> + CoreConstructible,
impl<J, N> JetConstructible<J> for Hiding<N>where
N: JetConstructible<J> + CoreConstructible,
Source§impl<W, N> WitnessConstructible<W> for Hiding<N>where
N: WitnessConstructible<W> + CoreConstructible,
impl<W, N> WitnessConstructible<W> for Hiding<N>where
N: WitnessConstructible<W> + CoreConstructible,
impl<N: Eq> Eq for Hiding<N>
impl<N> StructuralPartialEq for Hiding<N>
Auto Trait Implementations§
impl<N> Freeze for Hiding<N>where
N: Freeze,
impl<N> RefUnwindSafe for Hiding<N>where
N: RefUnwindSafe,
impl<N> Send for Hiding<N>where
N: Send,
impl<N> Sync for Hiding<N>where
N: Sync,
impl<N> Unpin for Hiding<N>where
N: Unpin,
impl<N> UnwindSafe for Hiding<N>where
N: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more