[−][src]Crate doublysure
DoublySure
Using types to make sure that you're sure, sure, and doubly sure
Users get prompted to make sure they want to perform a destructive action, why shouldn't developers?
This crate is composed of only the AreYouSure
enum, and the make_sure
macro. Check their individual documentation for more info.
Usage
The core usage is simple, when you encounter an AreYouSure
type you must
answer the question:
- Call
.yes_i_am_sure()
to run deferred functions and runwrap the value. - Or call
.no_i_am_not_sure()
to discard, doing nothing.
The make_sure
macro exists to wrap existing values, functions, and code
blocks in the AreYouSure
type.
Library Usage
DoublySure really shines when you use it within the public API of your own libraries as the return type of dangerous functions.
pub fn dangerous(num: usize) -> AreYouSure<Result<()>> { // Set things up... return make_sure!({ // dangerous operation that will not be run // until the user calls .yes_i_am_sure() }); }
Macros
make_sure | Macro to wrap values in an |
Enums
AreYouSure | A type that asks the user the all important question: Are you sure you want to do this? |