Skip to content

Commit

Permalink
capture: Fix docs around non-panicking group queries
Browse files Browse the repository at this point in the history
Previously in the regex::bytes implementation docs, we missed all of the
non-panicking versions that were supposed to be demonstrated. These now
show the correct versions.

In the str implementation, the indexed capture group examples were
correct, but not the named group examples. That's now also fixed.
  • Loading branch information
cdown committed Aug 22, 2018
1 parent 6b342fc commit 1e39165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/re_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ impl Regex {
/// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();
/// let text = b"Not my favorite movie: 'Citizen Kane' (1941).";
/// let caps = re.captures(text).unwrap();
/// assert_eq!(&caps[1], &b"Citizen Kane"[..]);
/// assert_eq!(&caps[2], &b"1941"[..]);
/// assert_eq!(&caps[0], &b"'Citizen Kane' (1941)"[..]);
/// assert_eq!(caps.get(1).unwrap().as_bytes(), &b"Citizen Kane"[..]);
/// assert_eq!(caps.get(2).unwrap().as_bytes(), &b"1941"[..]);
/// assert_eq!(caps.get(0).unwrap().as_bytes(), &b"'Citizen Kane' (1941)"[..]);
/// // You can also access the groups by index using the Index notation.
/// // Note that this will panic on an invalid index.
/// assert_eq!(&caps[1], b"Citizen Kane");
Expand All @@ -232,9 +232,9 @@ impl Regex {
/// .unwrap();
/// let text = b"Not my favorite movie: 'Citizen Kane' (1941).";
/// let caps = re.captures(text).unwrap();
/// assert_eq!(&caps["title"], &b"Citizen Kane"[..]);
/// assert_eq!(&caps["year"], &b"1941"[..]);
/// assert_eq!(&caps[0], &b"'Citizen Kane' (1941)"[..]);
/// assert_eq!(caps.name("title").unwrap().as_bytes(), b"Citizen Kane");
/// assert_eq!(caps.name("year").unwrap().as_bytes(), b"1941");
/// assert_eq!(caps.get(0).unwrap().as_bytes(), &b"'Citizen Kane' (1941)"[..]);
/// // You can also access the groups by name using the Index notation.
/// // Note that this will panic on an invalid group name.
/// assert_eq!(&caps["title"], b"Citizen Kane");
Expand Down
4 changes: 2 additions & 2 deletions src/re_unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ impl Regex {
/// .unwrap();
/// let text = "Not my favorite movie: 'Citizen Kane' (1941).";
/// let caps = re.captures(text).unwrap();
/// assert_eq!(&caps["title"], "Citizen Kane");
/// assert_eq!(&caps["year"], "1941");
/// assert_eq!(caps.name("title").unwrap().as_str(), "Citizen Kane");
/// assert_eq!(caps.name("year").unwrap().as_str(), "1941");
/// assert_eq!(caps.get(0).unwrap().as_str(), "'Citizen Kane' (1941)");
/// // You can also access the groups by name using the Index notation.
/// // Note that this will panic on an invalid group name.
Expand Down

0 comments on commit 1e39165

Please sign in to comment.