From 182a998e0f0757bd3e7bfcbcedbcccfba189f786 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 30 Jan 2021 23:28:01 +0100 Subject: [PATCH] Added close-matches example --- Cargo.toml | 4 ++++ examples/close-matches.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 examples/close-matches.rs diff --git a/Cargo.toml b/Cargo.toml index 2039036..33a11cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,7 @@ required-features = ["text"] [[example]] name = "udiff" required-features = ["text"] + +[[example]] +name = "close-matches" +required-features = ["text"] diff --git a/examples/close-matches.rs b/examples/close-matches.rs new file mode 100644 index 0000000..b88c9a9 --- /dev/null +++ b/examples/close-matches.rs @@ -0,0 +1,15 @@ +use similar::text::get_close_matches; + +fn main() { + let words = vec![ + "apple", + "appu", + "appal", + "apparitor", + "beer", + "beeb", + "beeline", + ]; + println!("{:?}", get_close_matches("app", &words, 3, 0.7)); + println!("{:?}", get_close_matches("bee", &words, 3, 0.7)); +}