mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibIPC: Add a Dictionary for-each method for fallible callbacks
Similar to a similar change to JsonObject (13b18a1
).
This commit is contained in:
parent
af2ae7fda1
commit
d0f3f3d5ff
Notes:
sideshowbarker
2024-07-18 01:43:16 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/d0f3f3d5ff Pull-request: https://github.com/SerenityOS/serenity/pull/16770
1 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
||||
|
@ -37,6 +38,14 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
template<FallibleFunction<DeprecatedString const&, DeprecatedString const&> Callback>
|
||||
ErrorOr<void> try_for_each_entry(Callback&& callback) const
|
||||
{
|
||||
for (auto const& it : m_entries)
|
||||
TRY(callback(it.key, it.value));
|
||||
return {};
|
||||
}
|
||||
|
||||
HashMap<DeprecatedString, DeprecatedString> const& entries() const { return m_entries; }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue