pub struct OutputSelection<'a, T, TermId> { /* private fields */ }Expand description
Wrap a multi-output Boolean function by selecting a single output.
§Example
use libreda_logic::traits::*;
use libreda_logic::native_boolean_functions::*;
use libreda_logic::adaptors::*;
fn f([a]: [bool; 1]) -> [bool; 2] {
[a, !a]
}
// Wrap the native Rust function such that it implements the traits of Boolean functions.
let f2 = NativeBooleanFunction::new(f);
// Select the first output.
let f_0 = OutputSelection::new(&f2, 0);
// Select the second output.
let f_1 = OutputSelection::new(&f2, 1);
assert_eq!(f_0.eval(&[false]), false);
assert_eq!(f_0.eval(&[true]), true);
assert_eq!(f_1.eval(&[false]), true);
assert_eq!(f_1.eval(&[true]), false);Implementations§
Source§impl<'a, T: BooleanSystem> OutputSelection<'a, T, T::TermId>
impl<'a, T: BooleanSystem> OutputSelection<'a, T, T::TermId>
Trait Implementations§
Source§impl<'a, T: BooleanSystem> BooleanFunction for OutputSelection<'a, T, T::TermId>
impl<'a, T: BooleanSystem> BooleanFunction for OutputSelection<'a, T, T::TermId>
Source§impl<'a, T: BooleanSystem> BooleanSystem for OutputSelection<'a, T, T::TermId>
impl<'a, T: BooleanSystem> BooleanSystem for OutputSelection<'a, T, T::TermId>
Source§impl<'a, T: NumInputs, TermId> NumInputs for OutputSelection<'a, T, TermId>
impl<'a, T: NumInputs, TermId> NumInputs for OutputSelection<'a, T, TermId>
Source§fn num_inputs(&self) -> usize
fn num_inputs(&self) -> usize
Get the number of inputs of the boolean function.
Source§impl<'a, T: NumOutputs, TermId> NumOutputs for OutputSelection<'a, T, TermId>
impl<'a, T: NumOutputs, TermId> NumOutputs for OutputSelection<'a, T, TermId>
Source§fn num_outputs(&self) -> usize
fn num_outputs(&self) -> usize
Get the number of outputs of the boolean function.
Source§impl<'a, T: PartialBooleanSystem> PartialBooleanFunction for OutputSelection<'a, T, T::TermId>
impl<'a, T: PartialBooleanSystem> PartialBooleanFunction for OutputSelection<'a, T, T::TermId>
Source§impl<'a, T: PartialBooleanSystem> PartialBooleanSystem for OutputSelection<'a, T, T::TermId>
impl<'a, T: PartialBooleanSystem> PartialBooleanSystem for OutputSelection<'a, T, T::TermId>
Source§type LiteralId = <T as PartialBooleanSystem>::LiteralId
type LiteralId = <T as PartialBooleanSystem>::LiteralId
An identifier for an input of the boolean formula.
impl<'a, T, TermId> StaticNumOutputs<1> for OutputSelection<'a, T, TermId>
Auto Trait Implementations§
impl<'a, T, TermId> Freeze for OutputSelection<'a, T, TermId>where
TermId: Freeze,
impl<'a, T, TermId> RefUnwindSafe for OutputSelection<'a, T, TermId>where
TermId: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, TermId> Send for OutputSelection<'a, T, TermId>
impl<'a, T, TermId> Sync for OutputSelection<'a, T, TermId>
impl<'a, T, TermId> Unpin for OutputSelection<'a, T, TermId>where
TermId: Unpin,
impl<'a, T, TermId> UnwindSafe for OutputSelection<'a, T, TermId>where
TermId: UnwindSafe,
T: RefUnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more