mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +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
|
@ -92,8 +92,10 @@ public:
|
|||
Optional<size_t> find_last_of(char) const;
|
||||
Optional<size_t> find_last_of(const StringView&) const;
|
||||
|
||||
Optional<size_t> find(const StringView&) const;
|
||||
Optional<size_t> find(char c) const;
|
||||
[[nodiscard]] Optional<size_t> find(char needle, size_t start = 0) const { return StringUtils::find(*this, needle, start); }
|
||||
[[nodiscard]] Optional<size_t> find(StringView const& needle, size_t start = 0) const { return StringUtils::find(*this, needle, start); }
|
||||
[[nodiscard]] Optional<size_t> find_last(char needle) const { return StringUtils::find_last(*this, needle); }
|
||||
// FIXME: Implement find_last(StringView const&) for API symmetry.
|
||||
|
||||
[[nodiscard]] constexpr StringView substring_view(size_t start, size_t length) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue