Crate infinitable

Source
Expand description

Infinity for types without infinite values

Infinitable introduces the notion of “infinity” and “negative infinity” to numeric types, such as integers, that do not have infinite values.

A representation of infinity is useful for graph algorithms such as Dijkstra’s algorithm, as well as for representing a graph with an adjacency matrix.

§Basic Usage

use infinitable::*;

let finite = Finite(5);
let infinity = Infinity;
let negative_infinity = NegativeInfinity;

assert!(finite < infinity);
assert!(finite > negative_infinity);

Re-exports§

pub use Infinitable::Finite;
pub use Infinitable::Infinity;
pub use Infinitable::NegativeInfinity;

Enums§

Infinitable
An “infinitable” value, one that can be either finite or infinite

Functions§

from_f32
Converts from f32 value to an optional Infinitable<f32>, accounting for floating-point infinities and NaN.
from_f64
Converts from f64 value to an optional Infinitable<f64>, accounting for floating-point infinities and NaN.