uniq_ch::precision

Enum Precision

Source
#[repr(u8)]
pub enum Precision {
Show 24 variants P1 = 0, P2 = 1, P3 = 2, P4 = 3, P5 = 4, P6 = 5, P7 = 6, P8 = 7, P9 = 8, P10 = 9, P11 = 10, P12 = 11, P13 = 12, P14 = 13, P15 = 14, P16 = 15, P17 = 16, P18 = 17, P19 = 18, P20 = 19, P21 = 20, P22 = 21, P23 = 22, P24 = 23,
}
Expand description

The precision of the BJKST data structure, in bits.

A Bjkst with precision p can store up to 2^p elements before shrinking. The internal array will be at most twice as large.

Default precision is 16 bits, that is, 65,536 elements.

Variants§

§

P1 = 0

1-bit precision.

§

P2 = 1

2-bit precision.

§

P3 = 2

3-bit precision.

§

P4 = 3

4-bit precision.

§

P5 = 4

5-bit precision.

§

P6 = 5

6-bit precision.

§

P7 = 6

7-bit precision.

§

P8 = 7

8-bit precision.

§

P9 = 8

9-bit precision.

§

P10 = 9

10-bit precision.

§

P11 = 10

11-bit precision.

§

P12 = 11

12-bit precision.

§

P13 = 12

13-bit precision.

§

P14 = 13

14-bit precision.

§

P15 = 14

15-bit precision.

§

P16 = 15

16-bit precision (default).

§

P17 = 16

17-bit precision.

§

P18 = 17

18-bit precision.

§

P19 = 18

19-bit precision.

§

P20 = 19

20-bit precision.

§

P21 = 20

21-bit precision.

§

P22 = 21

22-bit precision.

§

P23 = 22

23-bit precision.

§

P24 = 23

24-bit precision.

Implementations§

Source§

impl Precision

Source

pub const MIN: Self = Self::P1

The smallest precision value.

Source

pub const MAX: Self = Self::P24

The largest precision value.

Source

pub const fn new(value: u8) -> Option<Precision>

Creates a new Precision if the given value is valid.

Source

pub const fn get(&self) -> u8

Returns the precision value as a primitive type.

Source

pub const fn variants() -> &'static [Precision]

Returns the precision variants.

Source

pub fn in_range(&self, value: u8) -> bool

Checks whether the given value is in the range of available precisions.

Source

pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseError>

Converts a string slice in a given base to a precision.

The string is expected to be an optional + sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

Panics if radix is not in the range from 2 to 36.

§Examples
use uniq_ch::Precision;

assert_eq!(Precision::from_str_radix("10", 10), Ok(Precision::P10));

Trait Implementations§

Source§

impl Clone for Precision

Source§

fn clone(&self) -> Precision

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Precision

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Precision

Source§

fn default() -> Precision

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Precision

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Precision

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Precision> for u8

Source§

fn from(precision: Precision) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Precision

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Precision

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Precision

Source§

fn cmp(&self, other: &Precision) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Precision

Source§

fn eq(&self, other: &Precision) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Precision

Source§

fn partial_cmp(&self, other: &Precision) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Precision

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<u8> for Precision

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Precision

Source§

impl Eq for Precision

Source§

impl StructuralPartialEq for Precision

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,