@@ -1097,8 +1097,34 @@ impl str {
1097
1097
/// assert_eq!(d, &["", "", "", "", "a", "", "b", "c"]);
1098
1098
/// ```
1099
1099
///
1100
- /// This can lead to possibly surprising behavior when whitespace is used
1101
- /// as the separator. This code is correct:
1100
+ /// Contiguous separators are separated by the empty string.
1101
+ ///
1102
+ /// ```
1103
+ /// let x = "(///)".to_string();
1104
+ /// let d: Vec<_> = x.split('/').collect();;
1105
+ ///
1106
+ /// assert_eq!(d, &["(", "", "", ")"]);
1107
+ /// ```
1108
+ ///
1109
+ /// Separators at the start or end of a string are neighbored
1110
+ /// by empty strings.
1111
+ ///
1112
+ /// ```
1113
+ /// let d: Vec<_> = "010".split("0").collect();
1114
+ /// assert_eq!(d, &["", "1", ""]);
1115
+ /// ```
1116
+ ///
1117
+ /// When the empty string is used as a separator, it separates
1118
+ /// every character in the string, along with the beginning
1119
+ /// and end of the string.
1120
+ ///
1121
+ /// ```
1122
+ /// let f: Vec<_> = "rust".split("").collect();
1123
+ /// assert_eq!(f, &["", "r", "u", "s", "t", ""]);
1124
+ /// ```
1125
+ ///
1126
+ /// Contiguous separators can lead to possibly surprising behavior
1127
+ /// when whitespace is used as the separator. This code is correct:
1102
1128
///
1103
1129
/// ```
1104
1130
/// let x = " a b c".to_string();
0 commit comments