From d01ccf2516e79ad286e77044a877e6687b3d17a1 Mon Sep 17 00:00:00 2001 From: Chielo Newctle Date: Sun, 15 Oct 2023 11:46:28 +0800 Subject: [PATCH] chore(readme): add comments to the examples --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 8e54b7f..651c63d 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,10 @@ use general_sam::sam::GeneralSAM; let sam = GeneralSAM::construct_from_bytes("abcbc"); // => GeneralSAM +// "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()); ``` @@ -50,12 +53,20 @@ let sam = GeneralSAM::construct_from_chars("abcbc".chars()); // => GeneralSAM 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()); ```