diff --git a/src/regex/bytes.rs b/src/regex/bytes.rs index ea4f7cd65..7b7aad574 100644 --- a/src/regex/bytes.rs +++ b/src/regex/bytes.rs @@ -651,6 +651,9 @@ impl Regex { /// case, this implementation will likely return a `Cow::Borrowed` value /// such that no allocation is performed. /// + /// When a `Cow::Borrowed` is returned, the value returned is guaranteed + /// to be equivalent to the `haystack` given. + /// /// # Replacement string syntax /// /// All instances of `$ref` in the replacement string are replaced with @@ -761,6 +764,13 @@ impl Regex { /// replacement provided. This is the same as calling `replacen` with /// `limit` set to `0`. /// + /// If no match is found, then the haystack is returned unchanged. In that + /// case, this implementation will likely return a `Cow::Borrowed` value + /// such that no allocation is performed. + /// + /// When a `Cow::Borrowed` is returned, the value returned is guaranteed + /// to be equivalent to the `haystack` given. + /// /// The documentation for [`Regex::replace`] goes into more detail about /// what kinds of replacement strings are supported. /// @@ -855,6 +865,13 @@ impl Regex { /// matches are replaced. That is, `Regex::replace_all(hay, rep)` is /// equivalent to `Regex::replacen(hay, 0, rep)`. /// + /// If no match is found, then the haystack is returned unchanged. In that + /// case, this implementation will likely return a `Cow::Borrowed` value + /// such that no allocation is performed. + /// + /// When a `Cow::Borrowed` is returned, the value returned is guaranteed + /// to be equivalent to the `haystack` given. + /// /// The documentation for [`Regex::replace`] goes into more detail about /// what kinds of replacement strings are supported. /// diff --git a/src/regex/string.rs b/src/regex/string.rs index 824f45c69..dba94d46e 100644 --- a/src/regex/string.rs +++ b/src/regex/string.rs @@ -642,6 +642,9 @@ impl Regex { /// case, this implementation will likely return a `Cow::Borrowed` value /// such that no allocation is performed. /// + /// When a `Cow::Borrowed` is returned, the value returned is guaranteed + /// to be equivalent to the `haystack` given. + /// /// # Replacement string syntax /// /// All instances of `$ref` in the replacement string are replaced with @@ -748,6 +751,13 @@ impl Regex { /// replacement provided. This is the same as calling `replacen` with /// `limit` set to `0`. /// + /// If no match is found, then the haystack is returned unchanged. In that + /// case, this implementation will likely return a `Cow::Borrowed` value + /// such that no allocation is performed. + /// + /// When a `Cow::Borrowed` is returned, the value returned is guaranteed + /// to be equivalent to the `haystack` given. + /// /// The documentation for [`Regex::replace`] goes into more detail about /// what kinds of replacement strings are supported. /// @@ -842,6 +852,13 @@ impl Regex { /// matches are replaced. That is, `Regex::replace_all(hay, rep)` is /// equivalent to `Regex::replacen(hay, 0, rep)`. /// + /// If no match is found, then the haystack is returned unchanged. In that + /// case, this implementation will likely return a `Cow::Borrowed` value + /// such that no allocation is performed. + /// + /// When a `Cow::Borrowed` is returned, the value returned is guaranteed + /// to be equivalent to the `haystack` given. + /// /// The documentation for [`Regex::replace`] goes into more detail about /// what kinds of replacement strings are supported. ///