Skip to content

Commit

Permalink
Rollup merge of rust-lang#132606 - eduardosm:char-slice-str-pattern-d…
Browse files Browse the repository at this point in the history
…oc, r=tgross35

Improve example of `impl Pattern for &[char]`

The previous version used `['l', 'l']` as pattern, which would suggest that it matches the `ll` of `Hello world` as a whole.
  • Loading branch information
tgross35 authored Nov 5, 2024
2 parents 7094785 + 4872b6b commit fb4c4c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ impl<'a, 'b> DoubleEndedSearcher<'a> for CharSliceSearcher<'a, 'b> {}
/// # Examples
///
/// ```
/// assert_eq!("Hello world".find(&['l', 'l'] as &[_]), Some(2));
/// assert_eq!("Hello world".find(&['l', 'l'][..]), Some(2));
/// assert_eq!("Hello world".find(&['o', 'l'][..]), Some(2));
/// assert_eq!("Hello world".find(&['h', 'w'][..]), Some(6));
/// ```
impl<'b> Pattern for &'b [char] {
pattern_methods!('a, CharSliceSearcher<'a, 'b>, MultiCharEqPattern, CharSliceSearcher);
Expand Down

0 comments on commit fb4c4c9

Please sign in to comment.