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 7f1884213a
commit ec146caeea
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -78,7 +78,7 @@ template <typename T> class Vector
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));
@ -89,6 +89,11 @@ template <typename T> class Vector
return {};
}
Result<void> try_append(const T& item)
{
return try_append(T(item));
}
Option<T> try_pop()
{
if (m_size == 0) return {};