mirror of
https://codeberg.org/takouhai/strongbad_email.git
synced 2024-11-21 04:18:06 -05:00
fix: load file into binary and load from there
This commit is contained in:
parent
82aa779331
commit
ab14bfd267
1 changed files with 5 additions and 4 deletions
|
@ -1,9 +1,10 @@
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use rand::thread_rng;
|
use rand::thread_rng;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs;
|
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
|
static SBEMAILS_FILE: &'static[u8] = include_bytes!("sbemails.toml");
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Sbemails {
|
struct Sbemails {
|
||||||
emails: Vec<Emails>,
|
emails: Vec<Emails>,
|
||||||
|
@ -17,9 +18,9 @@ struct Emails {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Preeeeow, world.");
|
println!("Preeeeow, world.");
|
||||||
let toml_file = fs::read_to_string("src/sbemails.toml")
|
let sbemails: Sbemails = toml::from_str(
|
||||||
.expect("failed to read sbemails.toml");
|
std::str::from_utf8(SBEMAILS_FILE).unwrap()
|
||||||
let sbemails: Sbemails = toml::from_str(&toml_file)
|
)
|
||||||
.expect("failed to deserialize sbemails.toml");
|
.expect("failed to deserialize sbemails.toml");
|
||||||
let mut random_number = thread_rng();
|
let mut random_number = thread_rng();
|
||||||
let sbemail = sbemails.emails.choose(&mut random_number).unwrap();
|
let sbemail = sbemails.emails.choose(&mut random_number).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue