pub struct BalancedKey(/* private fields */);Expand description
create it like:
let _ = bisection_key::BalancedKey::new("a");Implementations§
Source§impl BalancedKey
impl BalancedKey
Sourcepub fn new(s: &str) -> Result<Self, String>
pub fn new(s: &str) -> Result<Self, String>
Examples found in repository?
examples/debug_balanced.rs (line 10)
5fn main() -> Result<(), String> {
6 // let a = BalancedKey::new("aV")?;
7 // let b = BalancedKey::new("b")?;
8 // println!("{}", a.bisect(&b)?);
9
10 let a0 = BalancedKey::new("aV")?;
11 let a1 = BalancedKey::new("b-")?;
12 a0.bisect(&a1)?;
13
14 let mut base = BalancedKey::new("a")?;
15 let next = BalancedKey::new("b")?;
16 let mut ret: Vec<String> = vec![];
17 for _ in 0..100 {
18 base = base.bisect(&next)?;
19 println!("{}", base);
20 ret.push(base.to_string());
21 }
22
23 println!("{:?}", ret);
24
25 let mut base = BalancedKey::new("a")?;
26 let mut ret: Vec<String> = vec![];
27 for _ in 0..100 {
28 base = base.bisect_end()?;
29 println!("{}", base);
30 ret.push(base.to_string());
31 }
32
33 println!("{:?}", ret);
34
35 Ok(())
36}pub fn strip_last_mut(&mut self)
pub fn strip_last(&self) -> Self
Sourcepub fn bisect(&self, next: &Self) -> Result<Self, String>
pub fn bisect(&self, next: &Self) -> Result<Self, String>
Examples found in repository?
examples/debug_balanced.rs (line 12)
5fn main() -> Result<(), String> {
6 // let a = BalancedKey::new("aV")?;
7 // let b = BalancedKey::new("b")?;
8 // println!("{}", a.bisect(&b)?);
9
10 let a0 = BalancedKey::new("aV")?;
11 let a1 = BalancedKey::new("b-")?;
12 a0.bisect(&a1)?;
13
14 let mut base = BalancedKey::new("a")?;
15 let next = BalancedKey::new("b")?;
16 let mut ret: Vec<String> = vec![];
17 for _ in 0..100 {
18 base = base.bisect(&next)?;
19 println!("{}", base);
20 ret.push(base.to_string());
21 }
22
23 println!("{:?}", ret);
24
25 let mut base = BalancedKey::new("a")?;
26 let mut ret: Vec<String> = vec![];
27 for _ in 0..100 {
28 base = base.bisect_end()?;
29 println!("{}", base);
30 ret.push(base.to_string());
31 }
32
33 println!("{:?}", ret);
34
35 Ok(())
36}Sourcepub fn bisect_end(&self) -> Result<Self, String>
pub fn bisect_end(&self) -> Result<Self, String>
Examples found in repository?
examples/debug_balanced.rs (line 28)
5fn main() -> Result<(), String> {
6 // let a = BalancedKey::new("aV")?;
7 // let b = BalancedKey::new("b")?;
8 // println!("{}", a.bisect(&b)?);
9
10 let a0 = BalancedKey::new("aV")?;
11 let a1 = BalancedKey::new("b-")?;
12 a0.bisect(&a1)?;
13
14 let mut base = BalancedKey::new("a")?;
15 let next = BalancedKey::new("b")?;
16 let mut ret: Vec<String> = vec![];
17 for _ in 0..100 {
18 base = base.bisect(&next)?;
19 println!("{}", base);
20 ret.push(base.to_string());
21 }
22
23 println!("{:?}", ret);
24
25 let mut base = BalancedKey::new("a")?;
26 let mut ret: Vec<String> = vec![];
27 for _ in 0..100 {
28 base = base.bisect_end()?;
29 println!("{}", base);
30 ret.push(base.to_string());
31 }
32
33 println!("{:?}", ret);
34
35 Ok(())
36}pub fn bisect_beginning(&self) -> Result<Self, String>
pub fn promote_from( &self, idx: usize, change: NumberChange, ) -> Result<Self, String>
pub fn checked(self) -> Result<Self, String>
Trait Implementations§
Source§impl Debug for BalancedKey
impl Debug for BalancedKey
Source§impl Default for BalancedKey
impl Default for BalancedKey
Source§impl Display for BalancedKey
impl Display for BalancedKey
Source§impl Ord for BalancedKey
missing length are filled with 32s, then compare like a vector
impl Ord for BalancedKey
missing length are filled with 32s, then compare like a vector
Source§fn cmp(&self, other: &BalancedKey) -> Ordering
fn cmp(&self, other: &BalancedKey) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for BalancedKey
missing length are filled with 32s, then compare like a vector
impl PartialEq for BalancedKey
missing length are filled with 32s, then compare like a vector
Source§impl PartialOrd for BalancedKey
impl PartialOrd for BalancedKey
impl Eq for BalancedKey
Auto Trait Implementations§
impl Freeze for BalancedKey
impl RefUnwindSafe for BalancedKey
impl Send for BalancedKey
impl Sync for BalancedKey
impl Unpin for BalancedKey
impl UnwindSafe for BalancedKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more