[−][src]Enum abi_stable::std_types::result::RResult
Ffi-safe equivalent of Result<T,E>
.
Variants
Implementations
impl<T, E> RResult<T, E>
[src]
pub fn as_ref(&self) -> RResult<&T, &E>
[src]
Converts from RResult<T,E>
to RResult<&T,&E>
.
Example
assert_eq!(ROk::<u32,u32>(10).as_ref(),ROk(&10)); assert_eq!(RErr::<u32,u32>(5).as_ref(),RErr(&5));
pub fn as_mut(&mut self) -> RResult<&mut T, &mut E>
[src]
Converts from RResult<T,E>
to RResult<&mut T,&mut E>
.
Example
assert_eq!(ROk::<u32,u32>(10).as_mut(),ROk(&mut 10)); assert_eq!(RErr::<u32,u32>(5).as_mut(),RErr(&mut 5));
pub fn is_rok(&self) -> bool
[src]
Returns whether self
is an ROk
Example
assert_eq!(ROk::<u32,u32>(10).is_rok(),true); assert_eq!(RErr::<u32,u32>(5).is_rok(),false);
pub fn is_ok(&self) -> bool
[src]
Returns whether self
is an ROk
Example
assert_eq!(ROk::<u32,u32>(10).is_ok(),true); assert_eq!(RErr::<u32,u32>(5).is_ok(),false);
pub fn is_rerr(&self) -> bool
[src]
Returns whether self
is an RErr
Example
assert_eq!(ROk::<u32,u32>(10).is_rerr(),false); assert_eq!(RErr::<u32,u32>(5).is_rerr(),true);
pub fn is_err(&self) -> bool
[src]
Returns whether self
is an RErr
Example
assert_eq!(ROk::<u32,u32>(10).is_err(),false); assert_eq!(RErr::<u32,u32>(5).is_err(),true);
pub fn into_result(self) -> Result<T, E>
[src]
Converts from RResult<T,E>
to Result<T,E>
.
Example
assert_eq!(ROk::<u32,u32>(10).into_result(),Ok (10)); assert_eq!(RErr::<u32,u32>(5).into_result(),Err(5));
pub fn map<U, F>(self, op: F) -> RResult<U, E> where
F: FnOnce(T) -> U,
[src]
F: FnOnce(T) -> U,
Converts the RResult<T,E>
to a RResult<U,E>
by transforming the value in ROk
using the op
closure.
Example
assert_eq!(ROk::<u32,u32>(10).map(|x| x*3 ),ROk(30)); assert_eq!(RErr::<u32,u32>(5).map(|x| x/2 ),RErr(5));
pub fn map_err<F, O>(self, op: O) -> RResult<T, F> where
O: FnOnce(E) -> F,
[src]
O: FnOnce(E) -> F,
Converts the RResult<T,E>
to a RResult<U,F>
by transforming the value in RErr
using the op
closure.
Example
assert_eq!(ROk::<u32,u32>(10).map_err(|x| x*3 ),ROk(10)); assert_eq!(RErr::<u32,u32>(5).map_err(|x| x/2 ),RErr(2));
pub fn map_or_else<U, M, F>(self, with_err: F, with_ok: M) -> U where
M: FnOnce(T) -> U,
F: FnOnce(E) -> U,
[src]
M: FnOnce(T) -> U,
F: FnOnce(E) -> U,
Converts the RResult<T,E>
to a U
by
transforming the value in ROk using the with_ok
closure,
otherwise transforming the value in RErr using the with_err
closure,
Example
assert_eq!(ROk::<u32,u32>(10).map_or_else(|_|77 ,|x| x*3 ),30); assert_eq!(RErr::<u32,u32>(5).map_or_else(|e|e*4,|x| x/2 ),20);
pub fn and_then<U, F>(self, op: F) -> RResult<U, E> where
F: FnOnce(T) -> RResult<U, E>,
[src]
F: FnOnce(T) -> RResult<U, E>,
Calls the op
closure with the value of ROk,
otherwise returning the RErr unmodified.
Example
assert_eq!( ROk::<u32,u32>(10).and_then(|x| ROk ::<u32,u32>(x*3) ), ROk (30), ); assert_eq!( ROk::<u32,u32>(10).and_then(|x| RErr::<u32,u32>(x*3)), RErr(30), ); assert_eq!( RErr::<u32,u32>(5).and_then(|x| ROk ::<u32,u32>(x/2) ), RErr(5), ); assert_eq!( RErr::<u32,u32>(5).and_then(|x| RErr::<u32,u32>(x/2) ), RErr(5), );
pub fn or_else<F, O>(self, op: O) -> RResult<T, F> where
O: FnOnce(E) -> RResult<T, F>,
[src]
O: FnOnce(E) -> RResult<T, F>,
Calls the op
closure with the value of RErr,
otherwise returning the ROk unmodified.
Example
assert_eq!(ROk::<u32,u32>(10).or_else(|e| ROk ::<u32,u32>(e*3) ) ,ROk(10)); assert_eq!(ROk::<u32,u32>(10).or_else(|e| RErr::<u32,u32>(e*3)) ,ROk(10)); assert_eq!(RErr::<u32,u32>(5).or_else(|e| ROk ::<u32,u32>(e/2) ),ROk (2)); assert_eq!(RErr::<u32,u32>(5).or_else(|e| RErr::<u32,u32>(e/2) ),RErr(2));
pub fn unwrap(self) -> T where
E: Debug,
[src]
E: Debug,
Unwraps self
, returning the value in Ok.
Panic
Panics if self
is an Err(_)
with an error message
using E
s Debug implementation.
Example
assert_eq!( ROk::<_,()>(500).unwrap(), 500 );
This one panics:
let _=RErr::<(),_>("Oh noooo!").unwrap();
pub fn expect(self, message: &str) -> T where
E: Debug,
[src]
E: Debug,
Unwraps self
, returning the value in Ok.
Panic
Panics if self
is an Err(_)
with an error message
using E
s Debug implementation,
as well as message
.
Example
assert_eq!( ROk::<_,()>(500).expect("Are you OK?"), 500 );
This one panics:
let _=RErr::<(),_>(()).expect("This can't be!");
pub fn unwrap_err(self) -> E where
T: Debug,
[src]
T: Debug,
Unwraps self
, returning the value in Err.
Panic
Panics if self
is an Ok(_)
with an error message
using T
s Debug implementation.
Example
assert_eq!( RErr::<(),u32>(0xB007).unwrap_err(), 0xB007 );
This one panics:
let _=ROk::<(),()>(()).unwrap_err();
pub fn expect_err(self, message: &str) -> E where
T: Debug,
[src]
T: Debug,
Unwraps self
, returning the value in Err.
Panic
Panics if self
is an Ok(_)
with an error message
using T
s Debug implementation,
as well as message
.
Example
assert_eq!( RErr::<(),u32>(0xB001).expect_err("Murphy's law"), 0xB001 );
This one panics:
let _=ROk::<(),()>(()).expect_err("Everything is Ok");
pub fn unwrap_or(self, optb: T) -> T
[src]
Returns the value in the RResult<T,E>
,or def
if self
is RErr
.
Example
assert_eq!(ROk::<u32,u32>(10).unwrap_or(0xEEEE),10); assert_eq!(RErr::<u32,u32>(5).unwrap_or(0b101010),0b101010);
pub fn unwrap_or_else<F>(self, op: F) -> T where
F: FnOnce(E) -> T,
[src]
F: FnOnce(E) -> T,
Returns the value in the RResult<T,E>
,
or calls def
with the error in RErr
.
Example
assert_eq!(ROk::<u32,u32>(10).unwrap_or_else(|e| e*3 ),10); assert_eq!(RErr::<u32,u32>(5).unwrap_or_else(|e| e/2 ),2);
pub fn unwrap_or_default(self) -> T where
T: Default,
[src]
T: Default,
Returns the value in the RResult<T,E>
,
or returns T::default()
it self
is an RErr
.
Example
assert_eq!(ROk::<u32,u32>(10).unwrap_or_default(),10); assert_eq!(RErr::<u32,u32>(5).unwrap_or_default(),0);
pub fn ok(self) -> ROption<T>
[src]
Converts from RResult<T, E> to ROption
Example
assert_eq!(ROk::<u32,u32>(10).ok(),RSome(10)); assert_eq!(RErr::<u32,u32>(5).ok(),RNone);
pub fn err(self) -> ROption<E>
[src]
Converts from RResult<T, E> to ROption
Example
assert_eq!(ROk::<u32,u32>(10).err(),RNone); assert_eq!(RErr::<u32,u32>(5).err(),RSome(5));
Trait Implementations
impl<T: Clone, E: Clone> Clone for RResult<T, E>
[src]
impl<T: Copy, E: Copy> Copy for RResult<T, E>
[src]
impl<T: Debug, E: Debug> Debug for RResult<T, E>
[src]
impl<'de, T, E> Deserialize<'de> for RResult<T, E> where
T: Deserialize<'de>,
E: Deserialize<'de>,
[src]
T: Deserialize<'de>,
E: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T: Eq, E: Eq> Eq for RResult<T, E>
[src]
impl<T, E> From<Result<T, E>> for RResult<T, E>
[src]
impl<T, E> GetStaticEquivalent_ for RResult<T, E> where
T: __StableAbi,
E: __StableAbi,
[src]
T: __StableAbi,
E: __StableAbi,
type StaticEquivalent = _static_RResult<__GetStaticEquivalent<T>, __GetStaticEquivalent<E>>
impl<T: Hash, E: Hash> Hash for RResult<T, E>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, E> Into<Result<T, E>> for RResult<T, E>
[src]
impl<T, E> IntoReprRust for RResult<T, E>
[src]
impl<T: Ord, E: Ord> Ord for RResult<T, E>
[src]
fn cmp(&self, other: &RResult<T, E>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq, E: PartialEq> PartialEq<RResult<T, E>> for RResult<T, E>
[src]
impl<T: PartialOrd, E: PartialOrd> PartialOrd<RResult<T, E>> for RResult<T, E>
[src]
fn partial_cmp(&self, other: &RResult<T, E>) -> Option<Ordering>
[src]
fn lt(&self, other: &RResult<T, E>) -> bool
[src]
fn le(&self, other: &RResult<T, E>) -> bool
[src]
fn gt(&self, other: &RResult<T, E>) -> bool
[src]
fn ge(&self, other: &RResult<T, E>) -> bool
[src]
impl<T, E> Serialize for RResult<T, E> where
T: Serialize,
E: Serialize,
[src]
T: Serialize,
E: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<T, E> SharedStableAbi for RResult<T, E> where
T: __StableAbi,
E: __StableAbi,
[src]
T: __StableAbi,
E: __StableAbi,
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
type Kind = __ValueKind
The kind of abi stability of this type,there are 2: Read more
const S_LAYOUT: &'static TypeLayout
[src]
const S_ABI_CONSTS: AbiConsts
[src]
impl<T, E> StructuralEq for RResult<T, E>
[src]
impl<T, E> StructuralPartialEq for RResult<T, E>
[src]
Auto Trait Implementations
impl<T, E> RefUnwindSafe for RResult<T, E> where
E: RefUnwindSafe,
T: RefUnwindSafe,
E: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, E> Send for RResult<T, E> where
E: Send,
T: Send,
E: Send,
T: Send,
impl<T, E> Sync for RResult<T, E> where
E: Sync,
T: Sync,
E: Sync,
T: Sync,
impl<T, E> Unpin for RResult<T, E> where
E: Unpin,
T: Unpin,
E: Unpin,
T: Unpin,
impl<T, E> UnwindSafe for RResult<T, E> where
E: UnwindSafe,
T: UnwindSafe,
E: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> BorrowOwned<'a> for T where
T: 'a + Clone,
[src]
T: 'a + Clone,
type ROwned = T
type RBorrowed = &'a T
fn r_borrow(
&'a <T as BorrowOwned<'a>>::ROwned
) -> <T as BorrowOwned<'a>>::RBorrowed
[src]
&'a <T as BorrowOwned<'a>>::ROwned
) -> <T as BorrowOwned<'a>>::RBorrowed
fn r_to_owned(
<T as BorrowOwned<'a>>::RBorrowed
) -> <T as BorrowOwned<'a>>::ROwned
[src]
<T as BorrowOwned<'a>>::RBorrowed
) -> <T as BorrowOwned<'a>>::ROwned
fn deref_borrowed(&<T as BorrowOwned<'a>>::RBorrowed) -> &T
[src]
fn deref_owned(&<T as BorrowOwned<'a>>::ROwned) -> &T
[src]
fn from_cow_borrow(&'a T) -> <T as BorrowOwned<'a>>::RBorrowed
[src]
fn from_cow_owned(<T as ToOwned>::Owned) -> <T as BorrowOwned<'a>>::ROwned
[src]
fn into_cow_borrow(<T as BorrowOwned<'a>>::RBorrowed) -> &'a T
[src]
fn into_cow_owned(<T as BorrowOwned<'a>>::ROwned) -> <T as ToOwned>::Owned
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<This> GetConstGenericVTable for This where
This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync,
[src]
This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync,
const VTABLE: ConstGenericVTableFor<This>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SelfOps for T where
T: ?Sized,
[src]
T: ?Sized,
const T: PhantomData<fn() -> Self>
[src]
const T_D: PhantomData<Self>
[src]
fn assert_ty(self, _other: PhantomData<fn() -> Self>) -> Self
[src]
fn assert_ty_ref(&self, _other: PhantomData<fn() -> Self>) -> &Self
[src]
fn assert_ty_mut(&mut self, _other: PhantomData<fn() -> Self>) -> &mut Self
[src]
fn ty_(&self) -> PhantomData<fn() -> Self>
[src]
fn ty_d(&self) -> PhantomData<Self>
[src]
fn ty_inv(&self) -> PhantomData<fn(Self) -> Self>
[src]
fn ty_inv_ref(&self) -> PhantomData<Cell<&Self>>
[src]
fn eq_id(&self, other: &Self) -> bool
[src]
fn piped<F, U>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> U where
F: FnOnce(&'a Self) -> U,
[src]
F: FnOnce(&'a Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U where
F: FnOnce(&'a mut Self) -> U,
[src]
F: FnOnce(&'a mut Self) -> U,
fn mutated<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
fn observe<F>(self, f: F) -> Self where
F: FnOnce(&Self),
[src]
F: FnOnce(&Self),
fn into_<T>(self, PhantomData<fn() -> T>) -> T where
Self: Into<T>,
[src]
Self: Into<T>,
fn as_ref_<T>(&self) -> &T where
Self: AsRef<T>,
T: ?Sized,
[src]
Self: AsRef<T>,
T: ?Sized,
fn as_mut_<T>(&mut self) -> &mut T where
Self: AsMut<T>,
T: ?Sized,
[src]
Self: AsMut<T>,
T: ?Sized,
fn drop_(self)
[src]
impl<This> StableAbi for This where
This: SharedStableAbi<Kind = ValueKind>,
[src]
This: SharedStableAbi<Kind = ValueKind>,
const LAYOUT: &'static TypeLayout
[src]
const ABI_CONSTS: AbiConsts
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<This> TransmuteElement for This where
This: ?Sized,
[src]
This: ?Sized,
unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
Self::Target: Sized,
[src]
Self: CanTransmuteElement<T>,
Self::Target: Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> TypeIdentity for T where
T: ?Sized,
[src]
T: ?Sized,
type Type = T
The same type as Self. Read more
fn into_type_val(self) -> Self::Type where
Self::Type: Sized,
[src]
Self::Type: Sized,
fn into_type_ref(&self) -> &Self::Type
[src]
fn into_type_mut(&mut self) -> &mut Self::Type
[src]
fn into_type_box(self: Box<Self>) -> Box<Self::Type>
[src]
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
[src]
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
[src]
fn from_type_val(this: Self::Type) -> Self where
Self::Type: Sized,
[src]
Self::Type: Sized,