Struct wooting_analog_common::SDKResult[][src]

pub struct SDKResult<T>(pub Result<T, WootingAnalogResult>);

Methods from Deref<Target = Result<T, WootingAnalogResult>>

#[must_use = "if you intended to assert that this is ok, consider `.unwrap()` instead"]
pub const fn is_ok(&self) -> bool
1.0.0 (const: 1.48.0)[src]

Returns true if the result is Ok.

Examples

Basic usage:

let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_ok(), true);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_ok(), false);

#[must_use = "if you intended to assert that this is err, consider `.unwrap_err()` instead"]
pub const fn is_err(&self) -> bool
1.0.0 (const: 1.48.0)[src]

Returns true if the result is Err.

Examples

Basic usage:

let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_err(), false);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_err(), true);

#[must_use]
pub fn contains<U>(&self, x: &U) -> bool where
    U: PartialEq<T>, 
[src]

🔬 This is a nightly-only experimental API. (option_result_contains)

Returns true if the result is an Ok value containing the given value.

Examples

#![feature(option_result_contains)]

let x: Result<u32, &str> = Ok(2);
assert_eq!(x.contains(&2), true);

let x: Result<u32, &str> = Ok(3);
assert_eq!(x.contains(&2), false);

let x: Result<u32, &str> = Err("Some error message");
assert_eq!(x.contains(&2), false);

#[must_use]
pub fn contains_err<F>(&self, f: &F) -> bool where
    F: PartialEq<E>, 
[src]

🔬 This is a nightly-only experimental API. (result_contains_err)

Returns true if the result is an Err value containing the given value.

Examples

#![feature(result_contains_err)]

let x: Result<u32, &str> = Ok(2);
assert_eq!(x.contains_err(&"Some error message"), false);

let x: Result<u32, &str> = Err("Some error message");
assert_eq!(x.contains_err(&"Some error message"), true);

let x: Result<u32, &str> = Err("Some other error message");
assert_eq!(x.contains_err(&"Some error message"), false);

pub const fn as_ref(&self) -> Result<&T, &E>1.0.0 (const: 1.48.0)[src]

Converts from &Result<T, E> to Result<&T, &E>.

Produces a new Result, containing a reference into the original, leaving the original in place.

Examples

Basic usage:

let x: Result<u32, &str> = Ok(2);
assert_eq!(x.as_ref(), Ok(&2));

let x: Result<u32, &str> = Err("Error");
assert_eq!(x.as_ref(), Err(&"Error"));

pub fn iter(&self) -> Iter<'_, T>1.0.0[src]

Returns an iterator over the possibly contained value.

The iterator yields one value if the result is Result::Ok, otherwise none.

Examples

Basic usage:

let x: Result<u32, &str> = Ok(7);
assert_eq!(x.iter().next(), Some(&7));

let x: Result<u32, &str> = Err("nothing!");
assert_eq!(x.iter().next(), None);

pub fn as_deref(&self) -> Result<&<T as Deref>::Target, &E>1.47.0[src]

Converts from Result<T, E> (or &Result<T, E>) to Result<&<T as Deref>::Target, &E>.

Coerces the Ok variant of the original Result via Deref and returns the new Result.

Examples

let x: Result<String, u32> = Ok("hello".to_string());
let y: Result<&str, &u32> = Ok("hello");
assert_eq!(x.as_deref(), y);

let x: Result<String, u32> = Err(42);
let y: Result<&str, &u32> = Err(&42);
assert_eq!(x.as_deref(), y);

Trait Implementations

impl<T: Debug> Debug for SDKResult<T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T> Default for SDKResult<T>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl<T> Deref for SDKResult<T>[src]

type Target = Result<T, WootingAnalogResult>

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl<'a> From<FfiStr<'a>> for SDKResult<FfiStr<'a>>[src]

fn from(res: FfiStr<'a>) -> Self[src]

Performs the conversion.

impl<T> From<Result<T, WootingAnalogResult>> for SDKResult<T>[src]

fn from(ptr: Result<T, WootingAnalogResult>) -> Self[src]

Performs the conversion.

impl<T> From<WootingAnalogResult> for SDKResult<T>[src]

fn from(res: WootingAnalogResult) -> Self[src]

Performs the conversion.

impl From<f32> for SDKResult<f32>[src]

fn from(res: f32) -> Self[src]

Performs the conversion.

impl From<i32> for SDKResult<c_int>[src]

fn from(res: c_int) -> Self[src]

Performs the conversion.

impl From<i32> for SDKResult<u32>[src]

fn from(res: c_int) -> Self[src]

Performs the conversion.

impl From<u32> for SDKResult<u32>[src]

fn from(res: u32) -> Self[src]

Performs the conversion.

impl<T> Into<Result<T, WootingAnalogResult>> for SDKResult<T>[src]

fn into(self) -> Result<T, WootingAnalogResult>[src]

Performs the conversion.

impl Into<WootingAnalogResult> for SDKResult<()>[src]

fn into(self) -> WootingAnalogResult[src]

Performs the conversion.

impl Into<f32> for SDKResult<f32>[src]

fn into(self) -> f32[src]

Performs the conversion.

impl Into<i32> for SDKResult<u32>[src]

fn into(self) -> i32[src]

Performs the conversion.

impl Into<i32> for SDKResult<c_int>[src]

fn into(self) -> c_int[src]

Performs the conversion.

Auto Trait Implementations

impl<T> RefUnwindSafe for SDKResult<T> where
    T: RefUnwindSafe

impl<T> Send for SDKResult<T> where
    T: Send

impl<T> Sync for SDKResult<T> where
    T: Sync

impl<T> Unpin for SDKResult<T> where
    T: Unpin

impl<T> UnwindSafe for SDKResult<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.