1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

AK: Make HashTable and HashMap try_* functions return ErrorOr<T>

This allows us to use TRY() and MUST() with them.
This commit is contained in:
Andreas Kling 2021-11-10 23:00:21 +01:00
parent 4eaa95769d
commit 9d1f238450
3 changed files with 22 additions and 37 deletions

View file

@ -49,8 +49,8 @@ public:
HashSetResult set(const K& key, const V& value) { return m_table.set({ key, value }); }
HashSetResult set(const K& key, V&& value) { return m_table.set({ key, move(value) }); }
HashSetResult try_set(const K& key, const V& value) { return m_table.try_set({ key, value }); }
HashSetResult try_set(const K& key, V&& value) { return m_table.try_set({ key, move(value) }); }
ErrorOr<HashSetResult> try_set(const K& key, const V& value) { return m_table.try_set({ key, value }); }
ErrorOr<HashSetResult> try_set(const K& key, V&& value) { return m_table.try_set({ key, move(value) }); }
bool remove(const K& key)
{
@ -91,7 +91,7 @@ public:
}
void ensure_capacity(size_t capacity) { m_table.ensure_capacity(capacity); }
bool try_ensure_capacity(size_t capacity) { return m_table.try_ensure_capacity(capacity); }
ErrorOr<void> try_ensure_capacity(size_t capacity) { return m_table.try_ensure_capacity(capacity); }
Optional<typename Traits<V>::PeekType> get(const K& key) const requires(!IsPointer<typename Traits<V>::PeekType>)
{