pub trait ResultExt<T, E>where
    E: Debug,
{ fn todo(self) -> T; fn assured(self, reason: &str) -> T; fn verified(self, reason: &str) -> T; }
Expand description

The extension trait for Result

Required Methods

Returns the contained Ok value, consuming the self value.

Use this method to indicate that it should be replaced with a better implementation later.

If disallow-todo-on-release feature is used, then the compilation will fail if debug_assertions are turned off (typically on a release build).

Panics

Panics if the value is an Err, with message “not yet implemented”, and the content of the Err.

Examples

Basic usage:

use meticulous::ResultExt;

let x: Result<u32, &str> = Err("emergency failure");
x.todo(); // panics with `not yet implemented: emergency failure`

Returns the contained Ok value, consuming the self value.

Use this method to indicate that you don’t expect the Result to be Err in any condition suitable for the program, e.g. u64 will always convert to usize if you target only 64-bit arch.

Panics

Panics if the value is an Err, with message “the success was expected to be assured, but the error was returned”, and the content of the Err.

Examples

Basic usage:

use meticulous::ResultExt;

let x: Result<u32, &str> = Err("emergency failure");
x.assured("always true for 64-bit apps"); // panics with `the success was expected to be assured, but the error was returned: always true for 64-bit apps: emergency failure`

Returns the contained Ok value, consuming the self value.

Use this method to indicate that conditions which may lead to Err result have already been checked in the code, so you never expect an error.

Panics

Panics if the value is an Err, with message “the success was expected to be verified in the code earlier, but the error was returned”, and the content of the Err.

Examples

Basic usage:

use meticulous::ResultExt;

let x: Result<u32, &str> = Err("emergency failure");
x.verified("boundaries already checked"); // panics with `the success was expected to be verified in the code earlier, but the error was returned: boundaries already checked: emergency failure`

Implementations on Foreign Types

Implementors