Coincidence detection as a crate
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
950 B

  1. use coincidence::*;
  2. use std::io::Read;
  3. fn main() {
  4. let mut args = std::env::args();
  5. if let Some(filepath) = args.nth(1) {
  6. let jewlist = get_jew_list();
  7. let mut file = std::fs::File::open(filepath).expect("you fucked up the filepath retard");
  8. let mut buf = String::new();
  9. file.read_to_string(&mut buf)
  10. .expect("somehow failed to read from string");
  11. let spans: Vec<Span> = Detector::new(&buf, &jewlist).collect();
  12. for (idx, c) in buf.char_indices() {
  13. let mut is_jewish = false;
  14. for span in &spans {
  15. if idx >= span.start && idx <= span.end {
  16. is_jewish = true;
  17. break;
  18. }
  19. }
  20. let color = if is_jewish { "\x1b[31m" } else { "\x1b[0m" };
  21. print!("{}{}", color, c);
  22. }
  23. } else {
  24. print!("Nice argument retard");
  25. }
  26. println!();
  27. }