docs.rs failed to build numlike-0.1.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
numlike-0.1.5
numlike
Numeric traits for generic mathematics. Less restrictive and less conservative
alternative to num-traits.
This crate has no unsafe code and no mandatory third-party dependencies, and
is no_std-compatible. However, when operating on floats, pow(), mul_add(),
div_euclid(), rem_euclid(), div_rem_euclid() functions and their checked
variants still require std.
Why numlike and not num-traits?
We developed numlike because we disagree with many of design decisions in
the venerable num-traits crate:
num-traits'sZeroandOnetraits respectively requireAddandMultraits to be implemented. This makes it impossible to distinguish a 0 for algebraic structures that don't implement addition (e.g. absorption magma and absorption monoid, aka. monoid with zero), and likewise 1 when there is no multiplication (e.g. because a naive implementation of multiplication for all elements would be inefficient).num-traitsalso requiresOutput = SelfforAddandMul, making it impossible to useZeroandOnefor statically-typed unit of measurement libraries likeuom.numlikedoes not have these problems because it does not have any supertraits for itsZeroandOnetraits.
- Moreover,
num-traits'sZeroandOnedo not provideZEROandONEassociated constants, but instead return them from::zero()and::one()functions. These constants were only later added through new separate traits,ConstZeroandConstOne, presumably to avoid breaking changes.numlike'sZeroandOneprovideZEROandONEassociated constants.
num-traits'sBoundedtrait only returns finite minimum and maximum values. This makes no difference for integers, but e.g. for floats.max_value()returnsf64::MAX, which is actually the largest finite number, not the positive infinity.num-traitshas no way to generically obtain positive or negative infinity as min. or max. value.numlikesolves that by providingMinExtended/MaxExtendedtraits that result in negative and positive infinities for floats, andMinFinite/MaxFinitetraits that give only finite values just as abovenum-traits'sBoundeddoes.
num-traitsprovides.signum()and.abs()methods only for types implementingSignedtrait, which excludes unsigned integer types.num-traitsdoes not provide checked mathematical operation traits,CheckedAdd,CheckedSub,CheckedMul,CheckedDiv,CheckedNeg,CheckedRem, for floats.numlikeimplements its own versions of these traits for all numeric primitives.
- Developers of
num-traitsseem to avoid breaking changes, strongly preferring to create new traits instead of making modifications to existing ones. This provides stability for users, but prevents at least some of the above issues from being solved.- Because of that, we have decided to roll our own library (this crate).
However, because it's in active development, we are lacking the stability of
num-traits, as we are likely to have many breaking changes.
- Because of that, we have decided to roll our own library (this crate).
However, because it's in active development, we are lacking the stability of
- Furthermore,
numlikealso has its own features, such as:- Equality and order traits that fix
NaNs to be the highest value in the set, even larger than positive infinity, allowing for total order:NanPartialEq,NanEq,NanPartialOrd,NanOrd.- But if you want
core::cmptraits instead, consider usingordered-floatcrate'sOrderedFloatfloat type wrapper instead. This is obviously often the better choice, becausecore::cmptraits will work with a much larger number of existing libraries and have Rust's syntactic sugar.
- But if you want
- Equality and order traits that fix