Struct exonum_configuration::MaybeVote
[−]
[src]
pub struct MaybeVote(_);
A functional equivalent to Option<Vote>
used to store votes in the service schema.
Notes
The None
variant of the type is represented by a Vote
with all bytes set to zero.
Methods
impl MaybeVote
[src]
pub fn none() -> Self
[src]
Creates a None
variant.
pub fn some(vote: Vote) -> Self
[src]
Creates a Some
variant.
Methods from Deref<Target = Option<Vote>>
pub fn is_some(&self) -> bool
1.0.0[src]
Returns true
if the option is a Some
value.
Examples
let x: Option<u32> = Some(2); assert_eq!(x.is_some(), true); let x: Option<u32> = None; assert_eq!(x.is_some(), false);
pub fn is_none(&self) -> bool
1.0.0[src]
Returns true
if the option is a None
value.
Examples
let x: Option<u32> = Some(2); assert_eq!(x.is_none(), false); let x: Option<u32> = None; assert_eq!(x.is_none(), true);
pub fn as_ref(&self) -> Option<&T>
1.0.0[src]
Converts from Option<T>
to Option<&T>
.
Examples
Convert an Option<
String
>
into an Option<
usize
>
, preserving the original.
The map
method takes the self
argument by value, consuming the original,
so this technique uses as_ref
to first take an Option
to a reference
to the value inside the original.
let num_as_str: Option<String> = Some("10".to_string()); // First, cast `Option<String>` to `Option<&String>` with `as_ref`, // then consume *that* with `map`, leaving `num_as_str` on the stack. let num_as_int: Option<usize> = num_as_str.as_ref().map(|n| n.len()); println!("still can print num_as_str: {:?}", num_as_str);
ⓘImportant traits for Iter<'a, A>pub fn iter(&self) -> Iter<T>
1.0.0[src]
Returns an iterator over the possibly contained value.
Examples
let x = Some(4); assert_eq!(x.iter().next(), Some(&4)); let x: Option<u32> = None; assert_eq!(x.iter().next(), None);
Trait Implementations
impl Clone for MaybeVote
[src]
fn clone(&self) -> MaybeVote
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for MaybeVote
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl PartialEq for MaybeVote
[src]
fn eq(&self, __arg_0: &MaybeVote) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &MaybeVote) -> bool
[src]
This method tests for !=
.
impl From<MaybeVote> for Option<Vote>
[src]
impl Deref for MaybeVote
[src]
type Target = Option<Vote>
The resulting type after dereferencing.
fn deref(&self) -> &Option<Vote>
[src]
Dereferences the value.