LinkedList: Make expect_first() and expect_last() show a more accurate error description on panic

Instead of showing a generic "Option::value() called on an empty Option" with no useful source location,
you will get something like "check failed: m_start_node at LinkedList.h:139"
This commit is contained in:
apio 2022-12-30 18:43:39 +01:00
parent 24773fbece
commit 1f36ecd044
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -136,7 +136,8 @@ template <typename T> class LinkedList
T* expect_first() T* expect_first()
{ {
return first().value(); check(m_start_node);
return m_start_node;
} }
Option<T*> last() Option<T*> last()
@ -146,7 +147,8 @@ template <typename T> class LinkedList
T* expect_last() T* expect_last()
{ {
return last().value(); check(m_end_node);
return m_end_node;
} }
Option<T*> next(T* item) Option<T*> next(T* item)