Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnikita committed Oct 5, 2023
1 parent 73ea3e3 commit 544ac19
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,26 @@ fn make_cpu(cmod: &Hash) -> Result<CpuBuilder> {
}

/// Find left and right indices of enumeration token in specification string
///
/// # Panics
///
/// Panics if the expression contains no or more than one token.
///
/// # Examples
///
/// ```
/// let cases = [
/// ("RELOAD?", (6, 0)),
/// ("TMR[1-57]_MUX", (3, 4)),
/// ("DT[1-3]?", (2, 0)),
/// ("GPIO[ABCDE]", (4, 0)),
/// ("CSPT[1][7-9],CSPT[2][0-5]", (4, 0)),
/// ];
/// for (spec, (li, ri)) in cases {
/// assert_eq!(patch::spec_ind(spec), (li, ri));
/// }
/// ```
///
fn spec_ind(spec: &str) -> (usize, usize) {
let spec = spec.split(',').next().unwrap_or(spec);
let re =
Expand Down

0 comments on commit 544ac19

Please sign in to comment.