interessant projectjen

This commit is contained in:
2023-01-20 16:05:32 +01:00
parent b21dd9b590
commit c5e3252ddc
4 changed files with 45 additions and 3 deletions

View File

@@ -7,3 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.91"
rfd = "0.10.0"
chatgpt_rs = "0.6.0"

View File

@@ -1,3 +1,37 @@
fn main() {
println!("Hello, world!");
use std::fs::File;
use std::io::{BufReader, Read};
use serde::{Serialize, Deserialize};
#[derive(Deserialize)]
struct MiniHuman {
name: String,
gender: String,
}
#[derive(Serialize)]
struct Human {
firstName: String,
lastName: String,
gender: String,
age: String,
country: String,
bio: String,
job: String,
}
fn main() {
let current_path = std::env::current_dir().unwrap();
let res = rfd::FileDialog::new().set_directory(&current_path).pick_file().unwrap();
let mut file = File::open(res.as_path()).unwrap();
let mut json_string:String = String::new();
file.read_to_string(&mut json_string).unwrap();
let MiniHumans: Vec<MiniHuman> = serde_json::from_str(&json_string).unwrap();
while MiniHumans.len() > 1 {
let firstName: String = getRngName(&MiniHumans);
let lastName: String = getRngName(&MiniHumans);
}
}
fn getRngName(miniHumans: &Vec<MiniHuman>) -> String {
return "".to_string()
}