Struct chain_impl_mockchain::vote::choice::Options
source · pub struct Options {
options_range: Range<u8>,
}
Expand description
options for the vote
currently this is a 4bits structure, allowing up to 16 choices however we may allow more complex object to be set in
Fields§
§options_range: Range<u8>
Implementations§
source§impl Options
impl Options
const NUM_CHOICES_MAX: u8 = 16u8
sourcepub fn new_length(num_choices: u8) -> Result<Self, InvalidOptionsLength>
pub fn new_length(num_choices: u8) -> Result<Self, InvalidOptionsLength>
create a new Options
with the given number of available choices
available choices will go from 0
to num_choices
not included.
sourcepub fn validate(&self, choice: Choice) -> bool
pub fn validate(&self, choice: Choice) -> bool
validate the given Choice
against the available Options
returns true
if the choice is valid, false
otherwise. By valid
it is meant as in the context of the available Options
. There is
obviously no wrong choices to make, only lessons to learn.
pub fn choice_range(&self) -> &Range<u8>
Trait Implementations§
source§impl PartialEq<Options> for Options
impl PartialEq<Options> for Options
impl Eq for Options
impl StructuralEq for Options
impl StructuralPartialEq for Options
Auto Trait Implementations§
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
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