@@ -1157,8 +1157,13 @@ impl str {
11571157 ///
11581158 /// Returns `false` if it does not.
11591159 ///
1160- /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
1160+ /// The [pattern] can be a `&str`, in which case this function will return true if
1161+ /// the `&str` is a prefix of this string slice.
1162+ ///
1163+ /// The [pattern] can also be a [`char`], a slice of [`char`]s, or a
11611164 /// function or closure that determines if a character matches.
1165+ /// These will only be checked against the first character of this string slice.
1166+ /// Look at the second example below regarding behavior for slices of [`char`]s.
11621167 ///
11631168 /// [`char`]: prim@char
11641169 /// [pattern]: self::pattern
@@ -1171,6 +1176,14 @@ impl str {
11711176 /// assert!(bananas.starts_with("bana"));
11721177 /// assert!(!bananas.starts_with("nana"));
11731178 /// ```
1179+ ///
1180+ /// ```
1181+ /// let bananas = "bananas";
1182+ ///
1183+ /// // Note that both of these assert successfully.
1184+ /// assert!(bananas.starts_with(&['b', 'a', 'n', 'a']));
1185+ /// assert!(bananas.starts_with(&['a', 'b', 'c', 'd']));
1186+ /// ```
11741187 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
11751188 pub fn starts_with < ' a , P : Pattern < ' a > > ( & ' a self , pat : P ) -> bool {
11761189 pat. is_prefix_of ( self )
0 commit comments