mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
AK: Add an AK::find
helper to return a reference to the found value
This is often more convenient than dealing with iterators. This commit includes a couple conversions to find_value as examples.
This commit is contained in:
parent
9cab5dc0c9
commit
7f37a8f60f
Notes:
github-actions[bot]
2025-04-06 11:46:22 +00:00
Author: https://github.com/trflynn89
Commit: 7f37a8f60f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4237
5 changed files with 34 additions and 30 deletions
|
@ -29,14 +29,9 @@ ReadonlySpan<AutocompleteEngine> autocomplete_engines()
|
|||
|
||||
Optional<AutocompleteEngine const&> find_autocomplete_engine_by_name(StringView name)
|
||||
{
|
||||
auto it = AK::find_if(builtin_autocomplete_engines.begin(), builtin_autocomplete_engines.end(),
|
||||
[&](auto const& engine) {
|
||||
return engine.name == name;
|
||||
});
|
||||
|
||||
if (it == builtin_autocomplete_engines.end())
|
||||
return {};
|
||||
return *it;
|
||||
return find_value(builtin_autocomplete_engines, [&](auto const& engine) {
|
||||
return engine.name == name;
|
||||
});
|
||||
}
|
||||
|
||||
Autocomplete::Autocomplete() = default;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue