summaryrefslogtreecommitdiff
path: root/absl/strings/strip.h
diff options
context:
space:
mode:
authorGravatar Dmitri Gribenko <dmitrig@google.com>2023-12-11 09:07:07 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-12-11 09:07:59 -0800
commit55621d1af55be7bf9a2c8e5dcef4368d9a6d4e51 (patch)
tree4c0e74b9a45b8875e35ee543089315a0d9989df1 /absl/strings/strip.h
parentfad946221cec37175e762c399760f54b9de9a9fa (diff)
Add nullability annotations
PiperOrigin-RevId: 589842893 Change-Id: I9657761d1f71c665582406f278c6605f6d382f6d
Diffstat (limited to 'absl/strings/strip.h')
-rw-r--r--absl/strings/strip.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/absl/strings/strip.h b/absl/strings/strip.h
index 341e66fc..e3cda5ba 100644
--- a/absl/strings/strip.h
+++ b/absl/strings/strip.h
@@ -25,6 +25,7 @@
#include <string>
#include "absl/base/macros.h"
+#include "absl/base/nullability.h"
#include "absl/strings/ascii.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
@@ -43,7 +44,8 @@ ABSL_NAMESPACE_BEGIN
// absl::string_view input("abc");
// EXPECT_TRUE(absl::ConsumePrefix(&input, "a"));
// EXPECT_EQ(input, "bc");
-inline bool ConsumePrefix(absl::string_view* str, absl::string_view expected) {
+inline bool ConsumePrefix(absl::Nonnull<absl::string_view*> str,
+ absl::string_view expected) {
if (!absl::StartsWith(*str, expected)) return false;
str->remove_prefix(expected.size());
return true;
@@ -59,7 +61,8 @@ inline bool ConsumePrefix(absl::string_view* str, absl::string_view expected) {
// absl::string_view input("abcdef");
// EXPECT_TRUE(absl::ConsumeSuffix(&input, "def"));
// EXPECT_EQ(input, "abc");
-inline bool ConsumeSuffix(absl::string_view* str, absl::string_view expected) {
+inline bool ConsumeSuffix(absl::Nonnull<absl::string_view*> str,
+ absl::string_view expected) {
if (!absl::EndsWith(*str, expected)) return false;
str->remove_suffix(expected.size());
return true;