@@ -452,6 +452,12 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
452452impl < ' a > DoubleEndedSearcher < ' a > for CharSearcher < ' a > { }
453453
454454/// Searches for chars that are equal to a given `char`.
455+ ///
456+ /// # Examples
457+ ///
458+ /// ```
459+ /// assert_eq!("Hello world".find('o'), Some(4));
460+ /// ```
455461impl < ' a > Pattern < ' a > for char {
456462 type Searcher = CharSearcher < ' a > ;
457463
@@ -697,6 +703,13 @@ unsafe impl<'a, 'b> ReverseSearcher<'a> for CharSliceSearcher<'a, 'b> {
697703impl < ' a , ' b > DoubleEndedSearcher < ' a > for CharSliceSearcher < ' a , ' b > { }
698704
699705/// Searches for chars that are equal to any of the chars in the array.
706+ ///
707+ /// # Examples
708+ ///
709+ /// ```
710+ /// assert_eq!("Hello world".find(&['l', 'l'] as &[_]), Some(2));
711+ /// assert_eq!("Hello world".find(&['l', 'l'][..]), Some(2));
712+ /// ```
700713impl < ' a , ' b > Pattern < ' a > for & ' b [ char ] {
701714 pattern_methods ! ( CharSliceSearcher <' a, ' b>, MultiCharEqPattern , CharSliceSearcher ) ;
702715}
@@ -739,6 +752,13 @@ where
739752impl < ' a , F > DoubleEndedSearcher < ' a > for CharPredicateSearcher < ' a , F > where F : FnMut ( char ) -> bool { }
740753
741754/// Searches for chars that match the given predicate.
755+ ///
756+ /// # Examples
757+ ///
758+ /// ```
759+ /// assert_eq!("Hello world".find(char::is_uppercase), Some(0));
760+ /// assert_eq!("Hello world".find(|c| "aeiou".contains(c)), Some(1));
761+ /// ```
742762impl < ' a , F > Pattern < ' a > for F
743763where
744764 F : FnMut ( char ) -> bool ,
@@ -763,6 +783,12 @@ impl<'a, 'b, 'c> Pattern<'a> for &'c &'b str {
763783///
764784/// Will handle the pattern `""` as returning empty matches at each character
765785/// boundary.
786+ ///
787+ /// # Examples
788+ ///
789+ /// ```
790+ /// assert_eq!("Hello world".find("world"), Some(6));
791+ /// ```
766792impl < ' a , ' b > Pattern < ' a > for & ' b str {
767793 type Searcher = StrSearcher < ' a , ' b > ;
768794
0 commit comments