From 48e12f9c95b886c2cb01a114f65719c33b69aa1c Mon Sep 17 00:00:00 2001
From: timofey <tim@ongoteam.yaconnect.com>
Date: Wed, 31 May 2023 15:25:52 +0000
Subject: [PATCH] fix `Bounds::join`

---
 book-monads                        | 2 +-
 src/rstd/collections/avl/bounds.rs | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/book-monads b/book-monads
index 8e9ea6c..d430fd9 160000
--- a/book-monads
+++ b/book-monads
@@ -1 +1 @@
-Subproject commit 8e9ea6c8e0db00818f4384127fabf6022be30daf
+Subproject commit d430fd9dca7e7ba7475f8be469c2eecb241c0def
diff --git a/src/rstd/collections/avl/bounds.rs b/src/rstd/collections/avl/bounds.rs
index fefa3f6..6d1b947 100644
--- a/src/rstd/collections/avl/bounds.rs
+++ b/src/rstd/collections/avl/bounds.rs
@@ -19,6 +19,7 @@ impl<A> Clone for Bounds<A> {
 
 pub enum BoundsError<A> {
     BoundsViolated { l: Rc<A>, r: Rc<A> },
+    CannotJoin(Rc<A>),
 }
 
 pub enum BoundError<A, E> {
@@ -113,13 +114,13 @@ impl<A> Bounds<A> {
     ) -> Result<Self, BoundsError<A>> {
         if let Some(lr) = &l.r {
             Self::ordered(lr, key, comparator)?
-        } else if let Some(ll) = &l.l {
-            Self::ordered(ll, key, comparator)?
+        } else {
+            Err(BoundsError::CannotJoin(key.clone()))?
         }
         if let Some(rl) = &r.l {
             Self::ordered(key, rl, comparator)?
-        } else if let Some(rr) = &r.r {
-            Self::ordered(key, rr, comparator)?
+        } else {
+            Err(BoundsError::CannotJoin(key.clone()))?
         }
         Self::new(l.l, r.r, comparator)
     }