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

Tuple Fields

0: Result<T, WootingAnalogResult>

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

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);
🔬 This is a nightly-only experimental API. (is_some_with)

Returns true if the result is Ok and the value inside of it matches a predicate.

Examples
#![feature(is_some_with)]

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

let x: Result<u32, &str> = Ok(0);
assert_eq!(x.is_ok_and(|&x| x > 1), false);

let x: Result<u32, &str> = Err("hey");
assert_eq!(x.is_ok_and(|&x| x > 1), false);

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);
🔬 This is a nightly-only experimental API. (is_some_with)

Returns true if the result is Err and the value inside of it matches a predicate.

Examples
#![feature(is_some_with)]
use std::io::{Error, ErrorKind};

let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true);

let x: Result<u32, Error> = Err(Error::new(ErrorKind::PermissionDenied, "!"));
assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false);

let x: Result<u32, Error> = Ok(123);
assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false);

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"));

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);

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);
🔬 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);
🔬 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);

Trait Implementations

Formats the value using the given formatter. Read more

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

The resulting type after dereferencing.

Dereferences the value.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.