Enum crowbook::BookOption
[−]
[src]
pub enum BookOption { String(String), Bool(bool), Char(char), Int(i32), Float(f32), Path(String), // some variants omitted }
Structure for storing a book option
This Enum might grow additional variants, so library users should not count on exhaustive matching.
Variants
String(String)
Stores a String
Bool(bool)
Stores a boolean
Char(char)
Stores a single char
Int(i32)
Stores an int
Float(f32)
Stores a float
Path(String)
Stores a path
Stored the same way as a string, but some base path is usually prepended to it
Methods
impl BookOption
[src]
fn as_str(&self) -> Result<&str>
Returns the BookOption as a &str, or an error if it isn't a String
variant
Examples
use crowbook::BookOption; let option = BookOption::String("foo".to_owned()); assert_eq!(option.as_str(), Ok("foo")); let option = BookOption::Int(42); assert!(option.as_str().is_err());Run
fn as_path(&self) -> Result<&str>
Returns the BookOption as a &str, on an error if it isn't a Path
variant.
fn as_bool(&self) -> Result<bool>
Retuns the BookOption as a bool, or an error if it isn't a Bool
variant.
fn as_char(&self) -> Result<char>
Returns the BookOption as a char, or an error if it isn't a Char
variant.
fn as_i32(&self) -> Result<i32>
Retuns the BookOption as an i32, or an error if it isn't an Int
variant.
fn as_f32(&self) -> Result<f32>
Returns the BookOption as an f32, or an error if it isn't a Float
variant.
Trait Implementations
impl Debug for BookOption
[src]
impl PartialEq for BookOption
[src]
fn eq(&self, __arg_0: &BookOption) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BookOption) -> bool
This method tests for !=
.
impl Clone for BookOption
[src]
fn clone(&self) -> BookOption
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more