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:
parent
24773fbece
commit
1f36ecd044
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user