yesorno

Crates.ioyesorno
lib.rsyesorno
version0.1.0
sourcesrc
created_at2021-09-12 13:54:56.31024
updated_at2021-09-12 13:54:56.31024
descriptionUseful for validating answers of a CLI prompt.
homepagehttps://github.com/sathishsoundharajan/yesorno
repositoryhttps://github.com/sathishsoundharajan/yesorno
max_upload_size
id450100
size8,008
Sathish (sathishsoundharajan)

documentation

https://docs.rs/yesorno

README

yesorno

Useful for validating answers of a CLI prompt.

Usage

extern crate yesorno;

fn main() {
  
  let is_yes = yesorno::is_yes("yes"); 
  println!("Is Yes ? : {}", is_yes);

  let is_no = yesorno::is_no("no"); 
  println!("Is No ? : {}", is_no);

  let is_lenient_yes = yesorno::is_lenient_yes("yrs"); 
  println!("Is lenient Yes ? : {}", is_lenient_yes);

  let is_lenient_no = yesorno::is_lenient_no("ni"); 
  println!("Is lenient No ? : {}", is_lenient_no);

  let is_yes_false = yesorno::is_yes("no"); 
  println!("Is Yes ? : {}", is_yes_false);
}

What is lenient ?

Use key distance based score to leniently accept typos of yes and no. This is slightly simple the original algorithm solved here in perl

Keyboard distance for fuzzy string matching. Keyboard distance is a measure of the physical distance between two keys on a keyboard. For example, 'g' has a distance of 1 from the keys 'r', 't', 'y', 'f', 'h', 'v', 'b', and 'n'. Immediate diagonals (like ''r, 'y', 'v', and 'n') are considered to have a distance of 0.75 and others are considered 0.25.

Similar Question

Commit count: 4

cargo fmt