summaryrefslogtreecommitdiff
path: root/absl/strings/strip.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-05-11 13:49:06 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-05-11 13:49:59 -0700
commitabbeeef82360d4a17f82d10fa1b1bb54feb2ad24 (patch)
tree9046bdb3fb172fa2787c1f2ebdd4f764fc70e36c /absl/strings/strip.h
parent5073947530a9c74ce6da63b1fac16cc07564a3b8 (diff)
Document that Consume(Prefix|Suffix)() don't modify the input on failure
PiperOrigin-RevId: 448075898 Change-Id: Ia4047f833bf27c62752b41f4ba65ab3be88a0181
Diffstat (limited to 'absl/strings/strip.h')
-rw-r--r--absl/strings/strip.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/absl/strings/strip.h b/absl/strings/strip.h
index 111872ca..d801774d 100644
--- a/absl/strings/strip.h
+++ b/absl/strings/strip.h
@@ -34,8 +34,9 @@ ABSL_NAMESPACE_BEGIN
// ConsumePrefix()
//
-// Strips the `expected` prefix from the start of the given string, returning
-// `true` if the strip operation succeeded or false otherwise.
+// Strips the `expected` prefix, if found, from the start of `str`.
+// If the operation succeeded, `true` is returned. If not, `false`
+// is returned and `str` is not modified.
//
// Example:
//
@@ -49,8 +50,9 @@ inline bool ConsumePrefix(absl::string_view* str, absl::string_view expected) {
}
// ConsumeSuffix()
//
-// Strips the `expected` suffix from the end of the given string, returning
-// `true` if the strip operation succeeded or false otherwise.
+// Strips the `expected` prefix, if found, from the end of `str`.
+// If the operation succeeded, `true` is returned. If not, `false`
+// is returned and `str` is not modified.
//
// Example:
//
@@ -65,7 +67,7 @@ inline bool ConsumeSuffix(absl::string_view* str, absl::string_view expected) {
// StripPrefix()
//
-// Returns a view into the input string 'str' with the given 'prefix' removed,
+// Returns a view into the input string `str` with the given `prefix` removed,
// but leaving the original string intact. If the prefix does not match at the
// start of the string, returns the original string instead.
ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix(
@@ -76,7 +78,7 @@ ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix(
// StripSuffix()
//
-// Returns a view into the input string 'str' with the given 'suffix' removed,
+// Returns a view into the input string `str` with the given `suffix` removed,
// but leaving the original string intact. If the suffix does not match at the
// end of the string, returns the original string instead.
ABSL_MUST_USE_RESULT inline absl::string_view StripSuffix(