mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
AK: Add String::substring(start)
This is a convenience API when you just want the rest of the string starting at some index. We already had substring_view() in the same flavor, so this is a complement to that.
This commit is contained in:
parent
e9280cba13
commit
5d0fda3d39
2 changed files with 8 additions and 0 deletions
|
@ -129,6 +129,13 @@ String String::isolated_copy() const
|
|||
return String(move(*impl));
|
||||
}
|
||||
|
||||
String String::substring(size_t start) const
|
||||
{
|
||||
ASSERT(m_impl);
|
||||
ASSERT(start <= length());
|
||||
return { characters() + start, length() - start };
|
||||
}
|
||||
|
||||
String String::substring(size_t start, size_t length) const
|
||||
{
|
||||
if (!length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue