Struct fractional_index::ZenoIndex [−][src]
pub struct ZenoIndex(_);
Expand description
A ZenoIndex
is a binary representation of a fraction between 0 and 1,
exclusive, with arbitrary precision.
The only operations it supports are:
- Construction of a
ZenoIndex
representing one half. - Comparison of two
ZenoIndex
values. - Returning an arbitrary
ZenoIndex
less or greater than another givenZenoIndex
. - Returning an arbitrary
ZenoIndex
strictly between two otherZenoIndex
es.
Note that as a result of these restrictions:
- It’s possible to arrive at a value infinitely close, but not equal to, zero or one (hence the name).
- We only ever care about the relative value of two
ZenoIndex
es; not their actual value. In fact, the only reason to think about them as fractions at all is because it makes them easier to reason about.
The use of fractional indexes for real-time editing of lists is described in this post. The specifics of the encoding used in that post differ from the one we use.
The underlying data structure used by a ZenoIndex is a vector of bytes. The fraction represented by a given vector of N bytes, where zi is the ith byte (1-based indexing):
(128/256)N + Σi=1..N (zi / 256i)
Implementations
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for ZenoIndex
impl UnwindSafe for ZenoIndex
Blanket Implementations
Mutably borrows from an owned value. Read more