pub struct Selector<'ctx, F> { /* private fields */ }Expand description
A tool for selecting among multiple items.
This is a generalization of using a BoolVar to select among two items,
letting you use k bits to select among 2^k items.
Implementations§
Source§impl<'ctx, F: Ring> Selector<'ctx, F>
impl<'ctx, F: Ring> Selector<'ctx, F>
Sourcepub fn new(bits: &[BoolVar<'ctx, F>]) -> Self
pub fn new(bits: &[BoolVar<'ctx, F>]) -> Self
Create a new selector, using a given number of in-circuit bits.
This selector will then be able to select among exactly 2^k items,
where k is the number of bits passed in here.
It is more efficient to create one selector and reuse it.
The selection is made in ascending order, i.e. 0..00, 0..01, 0..10, … In other words, if you pass in, e.g. 010 to this function, you then will always get the 3rd (index 2) of 8 items.
Sourcepub fn select_constant(&self, constants: &[F]) -> Var<'ctx, F>
pub fn select_constant(&self, constants: &[F]) -> Var<'ctx, F>
Select a constant value among 2^k possibilities.
Auto Trait Implementations§
impl<'ctx, F> !RefUnwindSafe for Selector<'ctx, F>
impl<'ctx, F> !UnwindSafe for Selector<'ctx, F>
impl<'ctx, F> Freeze for Selector<'ctx, F>
impl<'ctx, F> Send for Selector<'ctx, F>where
F: Send,
impl<'ctx, F> Sync for Selector<'ctx, F>
impl<'ctx, F> Unpin for Selector<'ctx, F>where
F: Unpin,
impl<'ctx, F> UnsafeUnpin for Selector<'ctx, F>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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