Commit abbeeef8 by Abseil Team Committed by Copybara-Service

Document that Consume(Prefix|Suffix)() don't modify the input on failure

PiperOrigin-RevId: 448075898
Change-Id: Ia4047f833bf27c62752b41f4ba65ab3be88a0181
parent 50739475
...@@ -34,8 +34,9 @@ ABSL_NAMESPACE_BEGIN ...@@ -34,8 +34,9 @@ ABSL_NAMESPACE_BEGIN
// ConsumePrefix() // ConsumePrefix()
// //
// Strips the `expected` prefix from the start of the given string, returning // Strips the `expected` prefix, if found, from the start of `str`.
// `true` if the strip operation succeeded or false otherwise. // If the operation succeeded, `true` is returned. If not, `false`
// is returned and `str` is not modified.
// //
// Example: // Example:
// //
...@@ -49,8 +50,9 @@ inline bool ConsumePrefix(absl::string_view* str, absl::string_view expected) { ...@@ -49,8 +50,9 @@ inline bool ConsumePrefix(absl::string_view* str, absl::string_view expected) {
} }
// ConsumeSuffix() // ConsumeSuffix()
// //
// Strips the `expected` suffix from the end of the given string, returning // Strips the `expected` prefix, if found, from the end of `str`.
// `true` if the strip operation succeeded or false otherwise. // If the operation succeeded, `true` is returned. If not, `false`
// is returned and `str` is not modified.
// //
// Example: // Example:
// //
...@@ -65,7 +67,7 @@ inline bool ConsumeSuffix(absl::string_view* str, absl::string_view expected) { ...@@ -65,7 +67,7 @@ inline bool ConsumeSuffix(absl::string_view* str, absl::string_view expected) {
// StripPrefix() // 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 // but leaving the original string intact. If the prefix does not match at the
// start of the string, returns the original string instead. // start of the string, returns the original string instead.
ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix( ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix(
...@@ -76,7 +78,7 @@ ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix( ...@@ -76,7 +78,7 @@ ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix(
// StripSuffix() // 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 // but leaving the original string intact. If the suffix does not match at the
// end of the string, returns the original string instead. // end of the string, returns the original string instead.
ABSL_MUST_USE_RESULT inline absl::string_view StripSuffix( ABSL_MUST_USE_RESULT inline absl::string_view StripSuffix(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment