Skip to main content

spos

Macro spos 

Source
macro_rules! spos {
    ($val:expr) => { ... };
}
Expand description

Macro for creating an optional Positive value from the given expression.

Returns Some(Positive) if the value is valid and non-negative, otherwise returns None. This is useful when you want to ignore errors.

ยงExample

use positive::spos;

let valid = spos!(5.0);
assert!(valid.is_some());

let invalid = spos!(-5.0);
assert!(invalid.is_none());