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]
impl<T, E> Finish<T, E>
pub fn new(value: T, error: Option<E>) -> Self
[src]
pub 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"));
pub fn unwrap(self) -> (T, Option<E>)
[src]
pub 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")));
pub fn into_result(self) -> Result<T, E>
[src]
pub 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"));
pub fn as_result(&self) -> Result<&T, &E>
[src]
pub 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: Debug, E: Debug> Debug for Finish<T, E>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Default, E: Default> Default for Finish<T, E>
[src]
impl<T: Default, E: Default> Default for Finish<T, E>
impl<T: Clone, E: Clone> Clone for Finish<T, E>
[src]
impl<T: Clone, E: Clone> Clone for Finish<T, E>
fn clone(&self) -> 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[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: PartialOrd, E: PartialOrd> PartialOrd for Finish<T, E>
[src]
impl<T: PartialOrd, E: PartialOrd> PartialOrd for Finish<T, E>
fn partial_cmp(&self, other: &Finish<T, E>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Finish<T, E>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Finish<T, E>) -> bool
[src]
fn lt(&self, other: &Finish<T, E>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Finish<T, E>) -> bool
[src]
fn le(&self, other: &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, other: &Finish<T, E>) -> bool
[src]
fn gt(&self, other: &Finish<T, E>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Finish<T, E>) -> bool
[src]
fn ge(&self, other: &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]
impl<T: Ord, E: Ord> Ord for Finish<T, E>
fn cmp(&self, other: &Finish<T, E>) -> Ordering
[src]
fn cmp(&self, other: &Finish<T, E>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T: PartialEq, E: PartialEq> PartialEq for Finish<T, E>
[src]
impl<T: PartialEq, E: PartialEq> PartialEq for Finish<T, E>
fn eq(&self, other: &Finish<T, E>) -> bool
[src]
fn eq(&self, other: &Finish<T, E>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Finish<T, E>) -> bool
[src]
fn ne(&self, other: &Finish<T, E>) -> bool
This method tests for !=
.
impl<T: Eq, E: Eq> Eq for Finish<T, E>
[src]
impl<T: Eq, E: Eq> Eq for Finish<T, E>
impl<T: Hash, E: Hash> Hash for Finish<T, E>
[src]
impl<T: Hash, E: Hash> Hash for Finish<T, E>