Vector: Fix try_append (hopefully)

Still doesn't work with OwnedStringViews inside of structs.
This commit is contained in:
apio 2023-02-27 15:02:55 +01:00
parent 01b6294f76
commit 4fc16915d3
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -78,7 +78,7 @@ template <typename T> class Vector
resize(capacity).release_value(); resize(capacity).release_value();
} }
Result<void> try_append(T item) Result<void> try_append(T&& item)
{ {
if (m_capacity == m_size) TRY(resize(m_capacity + 8)); if (m_capacity == m_size) TRY(resize(m_capacity + 8));
@ -89,6 +89,11 @@ template <typename T> class Vector
return {}; return {};
} }
Result<void> try_append(const T& item)
{
return try_append(T(item));
}
Option<T> try_pop() Option<T> try_pop()
{ {
if (m_size == 0) return {}; if (m_size == 0) return {};