Struct libflate::finish::Finish
[−]
[src]
pub struct Finish<T, E> { /* fields omitted */ }Finish is a type that represents a value which
may have an error occurred during the computation.
Logically, Finish<T, E> is equivalent to Result<T, (T, E)>.
Methods
impl<T, E> Finish<T, E>[src]
pub fn new(value: T, error: Option<E>) -> Self[src]
Makes a new instance.
Examples
use libflate::Finish; // The result value of a succeeded computation let succeeded = Finish::new("value", None as Option<()>); assert_eq!(succeeded.into_result(), Ok("value")); // The result value of a failed computation let failed = Finish::new("value", Some("error")); assert_eq!(failed.into_result(), Err("error"));
pub fn unwrap(self) -> (T, Option<E>)[src]
Unwraps the instance.
Examples
use libflate::Finish; let succeeded = Finish::new("value", None as Option<()>); assert_eq!(succeeded.unwrap(), ("value", None)); let failed = Finish::new("value", Some("error")); assert_eq!(failed.unwrap(), ("value", Some("error")));
pub fn into_result(self) -> Result<T, E>[src]
Converts from Finish<T, E> to Result<T, E>.
Examples
use libflate::Finish; let succeeded = Finish::new("value", None as Option<()>); assert_eq!(succeeded.into_result(), Ok("value")); let failed = Finish::new("value", Some("error")); assert_eq!(failed.into_result(), Err("error"));
pub fn as_result(&self) -> Result<&T, &E>[src]
Converts from Finish<T, E> to Result<&T, &E>.
Examples
use libflate::Finish; let succeeded = Finish::new("value", None as Option<()>); assert_eq!(succeeded.as_result(), Ok(&"value")); let failed = Finish::new("value", Some("error")); assert_eq!(failed.as_result(), Err(&"error"));
Trait Implementations
impl<T: Debug, E: Debug> Debug for Finish<T, E>[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl<T: Default, E: Default> Default for Finish<T, E>[src]
impl<T: Clone, E: Clone> Clone for Finish<T, E>[src]
fn clone(&self) -> Finish<T, E>[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<T: PartialOrd, E: PartialOrd> PartialOrd for Finish<T, E>[src]
fn partial_cmp(&self, __arg_0: &Finish<T, E>) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, __arg_0: &Finish<T, E>) -> bool[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, __arg_0: &Finish<T, E>) -> bool[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, __arg_0: &Finish<T, E>) -> bool[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, __arg_0: &Finish<T, E>) -> bool[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<T: Ord, E: Ord> Ord for Finish<T, E>[src]
fn cmp(&self, __arg_0: &Finish<T, E>) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<T: PartialEq, E: PartialEq> PartialEq for Finish<T, E>[src]
fn eq(&self, __arg_0: &Finish<T, E>) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Finish<T, E>) -> bool[src]
This method tests for !=.