LexiconKey

Struct LexiconKey 

Source
pub struct LexiconKey(/* private fields */);
Expand description

create it like:

let _  = bisection_key::LexiconKey::new("a");

Implementations§

Source§

impl LexiconKey

Source

pub fn new(s: &str) -> Result<Self, String>

Examples found in repository?
examples/debug_lexicon.rs (line 31)
5fn main() -> Result<(), String> {
6  // let a = LexiconKey::new("aV")?;
7  // let b = LexiconKey::new("b")?;
8  // println!("{}", a.bisect(&b)?);
9
10  // let mut base = LexiconKey::new("a")?;
11  // let next = LexiconKey::new("b")?;
12  // let mut ret: Vec<String> = vec![];
13  // for _ in 0..100 {
14  //   base = base.bisect(&next)?;
15  //   println!("{}", base);
16  //   ret.push(base.to_string());
17  // }
18
19  // println!("{:?}", ret);
20
21  // let mut base = LexiconKey::new("a")?;
22  // let mut ret: Vec<String> = vec![];
23  // for _ in 0..100 {
24  //   base = base.bisect_end()?;
25  //   println!("{}", base);
26  //   ret.push(base.to_string());
27  // }
28
29  // println!("{:?}", ret);
30
31  let mut base = LexiconKey::new("B")?;
32  let edge = LexiconKey::new("A")?;
33
34  for _ in 0..1000 {
35    base = base.bisect(&edge)?;
36    println!("{}", base);
37  }
38
39  Ok(())
40}
Source

pub fn bisect(&self, next: &Self) -> Result<Self, String>

Examples found in repository?
examples/debug_lexicon.rs (line 35)
5fn main() -> Result<(), String> {
6  // let a = LexiconKey::new("aV")?;
7  // let b = LexiconKey::new("b")?;
8  // println!("{}", a.bisect(&b)?);
9
10  // let mut base = LexiconKey::new("a")?;
11  // let next = LexiconKey::new("b")?;
12  // let mut ret: Vec<String> = vec![];
13  // for _ in 0..100 {
14  //   base = base.bisect(&next)?;
15  //   println!("{}", base);
16  //   ret.push(base.to_string());
17  // }
18
19  // println!("{:?}", ret);
20
21  // let mut base = LexiconKey::new("a")?;
22  // let mut ret: Vec<String> = vec![];
23  // for _ in 0..100 {
24  //   base = base.bisect_end()?;
25  //   println!("{}", base);
26  //   ret.push(base.to_string());
27  // }
28
29  // println!("{:?}", ret);
30
31  let mut base = LexiconKey::new("B")?;
32  let edge = LexiconKey::new("A")?;
33
34  for _ in 0..1000 {
35    base = base.bisect(&edge)?;
36    println!("{}", base);
37  }
38
39  Ok(())
40}
Source

pub fn bisect_end(&self) -> Result<Self, String>

Source

pub fn bisect_beginning(&self) -> Result<Self, String>

Source

pub fn promote_from( &self, idx: usize, change: NumberChange, ) -> Result<Self, String>

Source

pub fn checked(self) -> Result<Self, String>

Trait Implementations§

Source§

impl Debug for LexiconKey

Source§

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

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

impl Default for LexiconKey

Source§

fn default() -> Self

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

impl Display for LexiconKey

Source§

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

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

impl Ord for LexiconKey

missing length are filled with 32s, then compare like a vector

Source§

fn cmp(&self, other: &LexiconKey) -> 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 LexiconKey

missing length are filled with 32s, then compare like a vector

Source§

fn eq(&self, other: &LexiconKey) -> 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 LexiconKey

Source§

fn partial_cmp(&self, other: &LexiconKey) -> 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 Eq for LexiconKey

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> 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> 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.