mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:24:58 +00:00
AK: Reimplement StringView::find methods in StringUtils
This patch reimplements the StringView::find methods in StringUtils, so they can also be used by String. The methods now also take an optional start parameter, which moves their API in line with String's respective methods. This also implements a StringView::find_ast(char) method, which is currently functionally equivalent to find_last_of(char). This is because find_last_of(char) will be removed in a further commit.
This commit is contained in:
parent
3ea65200d8
commit
56253bf389
5 changed files with 37 additions and 20 deletions
|
@ -282,16 +282,6 @@ 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