Skip to content

Commit

Permalink
chore(readme): add comments to the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ChieloNewctle committed Oct 15, 2023
1 parent dbfa819 commit d01ccf2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ use general_sam::sam::GeneralSAM;
let sam = GeneralSAM::construct_from_bytes("abcbc");
// => GeneralSAM<u8>

// "cbc" is a suffix.
assert!(sam.get_root_state().feed_bytes("cbc").is_accepting());

// "bcb" isn't a suffix.
assert!(!sam.get_root_state().feed_bytes("bcb").is_accepting());
```

Expand All @@ -50,12 +53,20 @@ let sam = GeneralSAM::construct_from_chars("abcbc".chars());
// => GeneralSAM<char>

let state = sam.get_root_state();

// "b" is not a suffix but a substring.
let state = state.feed_chars("b");
assert!(!state.is_accepting());

// "bc" is a suffix.
let state = state.feed_chars("c");
assert!(state.is_accepting());

// "bcbc" is also a suffix.
let state = state.feed_chars("bc");
assert!(state.is_accepting());

// "bcbcbc" is not a substring.
let state = state.feed_chars("bc");
assert!(!state.is_accepting() && state.is_nil());
```
Expand Down

0 comments on commit d01ccf2

Please sign in to comment.