diff --git a/src/flow/binary.rs b/src/flow/binary.rs index f971dea..f86182e 100644 --- a/src/flow/binary.rs +++ b/src/flow/binary.rs @@ -29,7 +29,7 @@ pub trait BinaryTrees<'a>: 'a + Clone { fn split(&self, node: &Self::Node) -> Split<'a, Self>; fn tree_of(&self, node: Self::Node) -> BTWrap<'a, Self, Self::Tree>; fn resolve(&self, reference: &Self::Reference) -> BTWrap<'a, Self, Self::Node>; - fn equal(&self, rhs: &Self::Reference, lhs: &Self::Reference) -> bool; + fn equal(&self, rl: &Self::Reference, rr: &Self::Reference) -> bool; fn refer(&self, tree: &Self::Tree) -> Option; fn bind( @@ -192,8 +192,8 @@ pub trait BinaryTreesAvl<'a>: BinaryTrees<'a> { key: KeyRc<'a, Self>, tr: Self::Tree, ) -> BTWrap<'a, Self, Self::Node> { - let (lh, rh) = (self.height(&tl), self.height(&tr)); - match (lh.saturating_sub(rh), rh.saturating_sub(lh)) { + let (hl, hr) = (self.height(&tl), self.height(&tr)); + match (hl.saturating_sub(hr), hr.saturating_sub(hl)) { (0, 0) | (0, 1) | (1, 0) => self.join_key_unbalanced(tl, key, tr), (0, _) => Self::bind(self.assume_node(&tr), move |nr| { let (trl, trr, kr) = self.split(&nr); @@ -215,8 +215,8 @@ pub trait BinaryTreesAvl<'a>: BinaryTrees<'a> { }), (_, 0) => Self::bind(self.assume_node(&tl), move |nl| { let (tll, tlr, kl) = self.split(&nl); - let (llh, lrh) = (self.height(&tll), self.height(&tlr)); - if llh < lrh { + let (hll, hlr) = (self.height(&tll), self.height(&tlr)); + if hll < hlr { Self::bind(self.assume_node(&tlr), move |nlr| { let (tlrl, tlrr, klr) = self.split(&nlr); Self::T::bind2( diff --git a/src/flow/binary/avl.rs b/src/flow/binary/avl.rs index 5a2d819..edeb41f 100644 --- a/src/flow/binary/avl.rs +++ b/src/flow/binary/avl.rs @@ -29,8 +29,8 @@ impl Display for AvlN { #[cfg(test)] impl AvlN { fn balanced(&self) -> bool { - let (lh, rh) = (self.l.height, self.r.height); - std::cmp::max(lh, rh) - std::cmp::min(lh, rh) < 2 && self.l.balanced() && self.r.balanced() + let (hl, hr) = (self.l.height, self.r.height); + std::cmp::max(hl, hr) - std::cmp::min(hl, hr) < 2 && self.l.balanced() && self.r.balanced() } } diff --git a/src/func/instances/effect.rs b/src/func/instances/effect.rs index 327b56c..0817e17 100644 --- a/src/func/instances/effect.rs +++ b/src/func/instances/effect.rs @@ -14,7 +14,7 @@ pub trait Effect { fn e_pure() -> Self; /// Used in [`ApplicativeLA2::la2`] and other [`Applicative`] methods. - fn e_seq(lhs: Self, rhs: Self) -> Self; + fn e_seq(el: Self, er: Self) -> Self; /// Used in [`Monad::bind`] and other [`Monad`] methods. fn e_after(self, effect: Self) -> Self; diff --git a/src/func/instances/stackless.rs b/src/func/instances/stackless.rs index 325fc94..bbd6135 100644 --- a/src/func/instances/stackless.rs +++ b/src/func/instances/stackless.rs @@ -21,14 +21,14 @@ impl<'a> EvalTree<'a> { fn next(self) -> Oet<'a> { match self { EvalTree::Atom(f) => f(), - EvalTree::Composite(left, right) => match *left { + EvalTree::Composite(etl, etr) => match *etl { EvalTree::Atom(f) => match f() { - Some(newleft) => Some(EvalTree::Composite(Box::new(newleft), right)), - None => Some(*right), + Some(newleft) => Some(EvalTree::Composite(Box::new(newleft), etr)), + None => Some(*etr), }, - EvalTree::Composite(leftleft, leftright) => Some(EvalTree::Composite( - leftleft, - Box::new(EvalTree::Composite(leftright, right)), + EvalTree::Composite(etll, etlr) => Some(EvalTree::Composite( + etll, + Box::new(EvalTree::Composite(etlr, etr)), )), }, } @@ -61,14 +61,14 @@ impl<'a, A: 'a> Stackless<'a, A> { /// the preferred way to chain [`Stackless`] and `FnOnce(A) -> Stackless` into [`Stackless`]. pub fn bind(self, f: impl 'a + FnOnce(A) -> Stackless<'a, B>) -> Stackless<'a, B> { Stackless(Box::new(|takesb| { - let lcell = Rc::new(Cell::new(None)); - let rcell = lcell.clone(); + let cell_l = Rc::new(Cell::new(None)); + let cell_r = cell_l.clone(); Some(EvalTree::Composite( Box::new(EvalTree::Atom(Box::new(move || { - self.call(move |a| set_cell(lcell, a)) + self.call(move |a| set_cell(cell_l, a)) }))), Box::new(EvalTree::Atom(Box::new(move || { - let stackless = f(get_cell(rcell)); + let stackless = f(get_cell(cell_r)); Some(EvalTree::Atom(Box::new(|| stackless.0(takesb)))) }))), )) @@ -78,14 +78,14 @@ impl<'a, A: 'a> Stackless<'a, A> { /// Method-like equivalent of [`Functor::fmap`]. pub fn map(self, f: impl 'a + FnOnce(A) -> B) -> Stackless<'a, B> { Stackless(Box::new(|takesb| { - let lcell = Rc::new(Cell::new(None)); - let rcell = lcell.clone(); + let cell_l = Rc::new(Cell::new(None)); + let cell_r = cell_l.clone(); Some(EvalTree::Composite( Box::new(EvalTree::Atom(Box::new(move || { - self.call(move |a| set_cell(lcell, a)) + self.call(move |a| set_cell(cell_l, a)) }))), Box::new(EvalTree::Atom(Box::new(move || { - let b = f(get_cell(rcell)); + let b = f(get_cell(cell_r)); Some(EvalTree::Atom(Box::new(|| { takesb(b); None @@ -209,14 +209,14 @@ impl<'a> Monad<'a> for StacklessInstance { fn join(ffa: Self::F>) -> Self::F { Stackless(Box::new(|takesa| { - let lcell = Rc::new(Cell::new(None)); - let rcell = lcell.clone(); + let cell_l = Rc::new(Cell::new(None)); + let cell_r = cell_l.clone(); Some(EvalTree::Composite( Box::new(EvalTree::Atom(Box::new(move || { - ffa.call(move |a| set_cell(lcell, a)) + ffa.call(move |a| set_cell(cell_l, a)) }))), Box::new(EvalTree::Atom(Box::new(move || { - let stackless = get_cell(rcell); + let stackless = get_cell(cell_r); Some(EvalTree::Atom(Box::new(|| stackless.0(takesa)))) }))), )) diff --git a/src/func/tests.rs b/src/func/tests.rs index 7a3dd3c..6298f86 100644 --- a/src/func/tests.rs +++ b/src/func/tests.rs @@ -64,7 +64,7 @@ impl Add for R { success: self.success + rhs.success, total: self.total + rhs.total, result: match (self.result, rhs.result) { - (Err(le), Err(re)) => Err(le + "\n" + re.as_str()), + (Err(el), Err(er)) => Err(el + "\n" + er.as_str()), (e, Ok(_)) => e, (Ok(_), e) => e, }, @@ -77,12 +77,12 @@ impl AddAssign for R { self.success += rhs.success; self.total += rhs.total; match (&mut self.result, rhs.result) { - (Err(ref mut le), Err(re)) => { - *le += "\n"; - *le += re.as_str() + (Err(ref mut el), Err(er)) => { + *el += "\n"; + *el += er.as_str() } (_, Ok(_)) => {} - (lr, Err(re)) => *lr = Err(re), + (rl, Err(er)) => *rl = Err(er), } } } diff --git a/src/rcore/slice_deserializer.rs b/src/rcore/slice_deserializer.rs index b19e29e..572e536 100644 --- a/src/rcore/slice_deserializer.rs +++ b/src/rcore/slice_deserializer.rs @@ -19,17 +19,17 @@ impl<'a> From<&'a [u8]> for SliceDeserializer<'a> { impl<'a> Deserializer for SliceDeserializer<'a> { fn read_n(&mut self, n: usize) -> &[u8] { - let (left, right) = self.slice.split_at(min(n, self.slice.len())); - self.slice = right; - self.pos += left.len(); - left + let (slice_l, slice_r) = self.slice.split_at(min(n, self.slice.len())); + self.slice = slice_r; + self.pos += slice_l.len(); + slice_l } fn read_all(&mut self) -> &[u8] { - let left = self.slice; + let slice_l = self.slice; self.slice = &[]; - self.pos += left.len(); - left + self.pos += slice_l.len(); + slice_l } fn tell(&self) -> usize { diff --git a/src/rstd/collections/avl.rs b/src/rstd/collections/avl.rs index ebae195..59990b3 100644 --- a/src/rstd/collections/avl.rs +++ b/src/rstd/collections/avl.rs @@ -51,7 +51,7 @@ impl Display for AvlError { Self::LeafHeight(height) => { f.write_fmt(format_args!("invalid AVL leaf height: {height}!=0.")) } - Self::Balance(lh, rh) => f.write_fmt(format_args!("unbalanced AVL node: {lh} {rh}.")), + Self::Balance(hl, hr) => f.write_fmt(format_args!("unbalanced AVL node: {hl} {hr}.")), Self::HeightOverflow => f.write_fmt(format_args!("AVL tree height overflow")), Self::HeightMismatch { child, parent } => f.write_fmt(format_args!( "AVL child-parent height mismatch: {child:?}, {parent}" @@ -120,9 +120,9 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Avl } } -fn balanced(lh: u64, rh: u64) -> Result<(), AvlError> { - if std::cmp::max(lh, rh) - std::cmp::min(lh, rh) > 1 { - return Err(AvlError::Balance(lh, rh)); +fn balanced(hl: u64, hr: u64) -> Result<(), AvlError> { + if std::cmp::max(hl, hr) - std::cmp::min(hl, hr) > 1 { + return Err(AvlError::Balance(hl, hr)); } Ok(()) } diff --git a/src/rstd/collections/avl/bounds.rs b/src/rstd/collections/avl/bounds.rs index 3cff077..819e833 100644 --- a/src/rstd/collections/avl/bounds.rs +++ b/src/rstd/collections/avl/bounds.rs @@ -113,28 +113,31 @@ impl Bounds { ) -> Result> { if let Some(lr) = &l.r { Self::ordered(lr, key, comparator)? + } else if let Some(ll) = &l.l { + Self::ordered(ll, key, comparator)? } if let Some(rl) = &r.l { Self::ordered(key, rl, comparator)? + } else if let Some(rr) = &r.r { + Self::ordered(key, rr, comparator)? } Self::new(l.l, r.r, comparator) } pub fn equal_bound( - lhs: &Option>, - rhs: &Option>, + l: &Option>, + r: &Option>, comparator: &impl Comparator, ) -> bool { - match (lhs, rhs) { + match (l, r) { (None, None) => true, (Some(kl), Some(kr)) => matches!(comparator.pick_smaller(kl, kr), Comparison::E), _ => false, } } - pub fn equal(lhs: &Self, rhs: &Self, comparator: &impl Comparator) -> bool { - Self::equal_bound(&lhs.l, &rhs.l, comparator) - && Self::equal_bound(&lhs.r, &rhs.r, comparator) + pub fn equal(bl: &Self, br: &Self, comparator: &impl Comparator) -> bool { + Self::equal_bound(&bl.l, &br.l, comparator) && Self::equal_bound(&bl.r, &br.r, comparator) } } @@ -273,7 +276,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> BoundReference<'a, Ctx, A> { }) } - pub fn equal(lhs: &Self, rhs: &Self, comparator: &impl Comparator) -> bool { - lhs.reference == rhs.reference && Bounds::equal(&lhs.bounds, &rhs.bounds, comparator) + pub fn equal(rl: &Self, rr: &Self, comparator: &impl Comparator) -> bool { + rl.reference == rr.reference && Bounds::equal(&rl.bounds, &rr.bounds, comparator) } } diff --git a/src/rstd/collections/avl/context.rs b/src/rstd/collections/avl/context.rs index c4f89b2..4d2f047 100644 --- a/src/rstd/collections/avl/context.rs +++ b/src/rstd/collections/avl/context.rs @@ -50,8 +50,8 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>, C: 'a + Comparator> Binar Ctx::stuff(reference.resolve(self.comparator.clone())) } - fn equal(&self, rhs: &Self::Reference, lhs: &Self::Reference) -> bool { - BoundReference::equal(lhs, rhs, self.comparator.as_ref()) + fn equal(&self, rl: &Self::Reference, rr: &Self::Reference) -> bool { + BoundReference::equal(rl, rr, self.comparator.as_ref()) } fn refer(&self, tree: &Self::Tree) -> Option { diff --git a/src/rstd/tracing.rs b/src/rstd/tracing.rs index e0792c5..a349463 100644 --- a/src/rstd/tracing.rs +++ b/src/rstd/tracing.rs @@ -31,8 +31,8 @@ impl instances::effect::Effect for TraceBox { TraceBox::pure() } - fn e_seq(lhs: Self, rhs: Self) -> Self { - TraceBox::parallel(lhs, rhs) + fn e_seq(el: Self, er: Self) -> Self { + TraceBox::parallel(el, er) } fn e_after(self, effect: Self) -> Self { diff --git a/src/testing/counted.rs b/src/testing/counted.rs index 13a833b..53a0a62 100644 --- a/src/testing/counted.rs +++ b/src/testing/counted.rs @@ -29,8 +29,8 @@ impl instances::effect::Effect for usize { 0 } - fn e_seq(lhs: Self, rhs: Self) -> Self { - max(lhs, rhs) + fn e_seq(el: Self, er: Self) -> Self { + max(el, er) } fn e_after(self, effect: Self) -> Self {