BAN: Add Front() and Back() to StringView

This commit is contained in:
Bananymous 2023-01-16 18:56:51 +02:00
parent e307db47eb
commit 5122d27f89
2 changed files with 15 additions and 0 deletions

View File

@ -104,6 +104,18 @@ namespace BAN
return result;
}
char StringView::Back() const
{
ASSERT(m_size > 0);
return m_data[m_size - 1];
}
char StringView::Front() const
{
ASSERT(m_size > 0);
return m_data[0];
}
StringView::size_type StringView::Count(char ch) const
{
size_type result = 0;

View File

@ -27,6 +27,9 @@ namespace BAN
[[nodiscard]] ErrorOr<Vector<StringView>> Split(char, bool = false);
[[nodiscard]] ErrorOr<Vector<StringView>> Split(bool(*comp)(char), bool = false);
char Back() const;
char Front() const;
size_type Count(char) const;
bool Empty() const;