pub struct Bound(/* private fields */);Expand description
A strict bound x - y < c, a non-strict bound x - y <= c,
or infinity (no restriction on the difference).
Construct bounds with Bound::lt, Bound::le, or
Bound::INFINITY.
The Ord implementation orders bounds by tightness: smaller bounds
exclude at least as many valuations.
§Example
use clock_dbm::Bound;
assert!(Bound::lt(3)? < Bound::le(3)?);
assert_eq!(Bound::lt(2)?.checked_add(Bound::le(3)?)?, Bound::lt(5)?);
assert!(Bound::INFINITY.is_infinite());Implementations§
Source§impl Bound
impl Bound
Sourcepub const fn le(c: i32) -> Result<Bound, Error>
pub const fn le(c: i32) -> Result<Bound, Error>
Constructs the non-strict upper bound <= c.
Returns Error::Range if c is outside the supported interval
from MIN_CONSTANT to MAX_CONSTANT.
Sourcepub const fn lt(c: i32) -> Result<Bound, Error>
pub const fn lt(c: i32) -> Result<Bound, Error>
Constructs the strict upper bound < c.
Returns Error::Range if c is outside the supported interval
from MIN_CONSTANT to MAX_CONSTANT.
Sourcepub const fn is_infinite(self) -> bool
pub const fn is_infinite(self) -> bool
Whether this is ∞.
Sourcepub const fn is_strict(self) -> bool
pub const fn is_strict(self) -> bool
Returns whether the bound uses < rather than <=.
An unrestricted (infinite) bound is not strict.
Sourcepub const fn constant(self) -> Option<i32>
pub const fn constant(self) -> Option<i32>
Returns the integer constant of a finite strict or non-strict
bound, or None for an unrestricted (infinite) bound.
Sourcepub const fn checked_add(self, other: Bound) -> Result<Bound, Error>
pub const fn checked_add(self, other: Bound) -> Result<Bound, Error>
Adds two bounds, as when chaining clock-difference inequalities.
The finite constants are added; the result is strict (<) if
either operand is strict. If either bound is infinite, so is the
sum. Returns Error::Range if a finite sum cannot be represented;
it is never saturated to infinity.