mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
AK: Add String{View,}::find(StringView)
I personally mistook `find_first_of(StringView)` to be analogous to this so let's add a `find()` method that actually searches the string.
This commit is contained in:
parent
4fa8435310
commit
39442e6d4f
Notes:
sideshowbarker
2024-07-18 23:53:03 +09:00
Author: https://github.com/alimpfard
Commit: 39442e6d4f
Pull-request: https://github.com/SerenityOS/serenity/pull/4929
Issue: https://github.com/SerenityOS/serenity/issues/4926
8 changed files with 70 additions and 11 deletions
|
@ -310,6 +310,16 @@ Optional<size_t> StringView::find_last_of(const StringView& view) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<size_t> StringView::find(char c) const
|
||||
{
|
||||
return find(StringView { &c, 1 });
|
||||
}
|
||||
|
||||
Optional<size_t> StringView::find(const StringView& view) const
|
||||
{
|
||||
return StringUtils::find(*this, view);
|
||||
}
|
||||
|
||||
String StringView::to_string() const { return String { *this }; }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue