diff options
Diffstat (limited to 'source/fud_string.cpp')
-rw-r--r-- | source/fud_string.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/fud_string.cpp b/source/fud_string.cpp index fa34cc9..cd3e918 100644 --- a/source/fud_string.cpp +++ b/source/fud_string.cpp @@ -371,9 +371,23 @@ FudStatus String::reserve(size_t newCapacity) return resize(newCapacity); } +[[nodiscard]] Option<utf8> String::front() +{ + if (!valid() || length() < 1) { + return NullOpt; + } + + utf8 frontChar = dataMut()[0]; + if (Ascii::valid(frontChar)) { + return frontChar; + } + + return NullOpt; +} + [[nodiscard]] Option<utf8> String::back() { - if (!valid()) { + if (!valid() || length() < 1) { return NullOpt; } @@ -443,7 +457,7 @@ FudStatus String::pushBack(utf8 letter) return FudStatus::Success; } -FudStatus String::pushBack(const FudUtf8& letter) +FudStatus String::pushBack(const Utf8& letter) { if (!valid()) { return FudStatus::StringInvalid; |