Struct libflate::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]
fn new(value: T, error: Option<E>) -> Self
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"));
fn unwrap(self) -> (T, Option<E>)
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")));
fn into_result(self) -> Result<T, E>
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"));
fn as_result(&self) -> Result<&T, &E>
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]
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>
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
impl<T: PartialOrd, E: PartialOrd> PartialOrd for Finish<T, E>
[src]
fn partial_cmp(&self, __arg_0: &Finish<T, E>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Finish<T, E>) -> bool
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
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
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
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
This method returns an Ordering
between self
and other
. Read more
impl<T: PartialEq, E: PartialEq> PartialEq for Finish<T, E>
[src]
fn eq(&self, __arg_0: &Finish<T, E>) -> bool
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
This method tests for !=
.