@@ -2492,12 +2492,14 @@ impl str {
24922492
24932493 /// Returns a string slice with the prefix and suffix removed.
24942494 ///
2495- /// If the string starts with the pattern `prefix` and ends with the pattern `suffix`, returns
2495+ /// If the string starts with the pattern `prefix` and ends with
2496+ /// the pattern `suffix`, and the prefix and suffix don't overlap, returns
24962497 /// the substring after the prefix and before the suffix, wrapped in `Some`.
24972498 /// Unlike [`trim_start_matches`] and [`trim_end_matches`], this method removes both the prefix
24982499 /// and suffix exactly once.
24992500 ///
2500- /// If the string does not start with `prefix` or does not end with `suffix`, returns `None`.
2501+ /// If the string does not start with `prefix`, does not end with `suffix`,
2502+ /// or the prefix and suffix overlap in the string, returns `None`.
25012503 ///
25022504 /// Each [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
25032505 /// function or closure that determines if a character matches.
@@ -2513,6 +2515,7 @@ impl str {
25132515 /// assert_eq!("bar:hello:foo".strip_circumfix("bar:", ":foo"), Some("hello"));
25142516 /// assert_eq!("bar:foo".strip_circumfix("foo", "foo"), None);
25152517 /// assert_eq!("foo:bar;".strip_circumfix("foo:", ';'), Some("bar"));
2518+ /// assert_eq!("foo:bar:baz".strip_circumfix("foo:bar:", ":bar:baz"), None);
25162519 /// ```
25172520 #[ must_use = "this returns the remaining substring as a new slice, \
25182521 without modifying the original"]
0 commit comments