gender_identification/
lib.rs1use std::fs::File;
2use std::io::Read;
3pub fn gender_identification(com: String){
5 let mut text_boy = File::open("boysname.txt").expect("boys file not open");
6 let mut text_girl = File::open("girlsname.txt").expect("girls file not open");
7 let mut seperate_boy = String::new();
8 let mut seperate_girl = String::new();
9 text_boy.read_to_string(&mut seperate_boy).expect("boys file not read");
10 text_girl.read_to_string(&mut seperate_girl).expect("girls file not read");
11 let compare= com;
12 let mut is_found_boy = false;
13 let mut is_found_girl = false;
14 for word in seperate_boy.split("\r\n"){
15 if word==compare{
16 is_found_boy = true;
17 }
18 }
19 for word in seperate_girl.split("\r\n"){
20 if word==compare{
21 is_found_girl = true;
22 }
23 }
24 if is_found_boy
25 {
26 println!("{}: Gender is Male ",compare);
27 }
28 else if is_found_girl{
29 println!("{} : Gender is Female ",compare);
30 }
31 else{
32 println!(".......sorry this name is not our Database.......");
33 }
34 }