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::thread_rng;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
use toml;
|
||||
|
||||
static SBEMAILS_FILE: &'static[u8] = include_bytes!("sbemails.toml");
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Sbemails {
|
||||
emails: Vec<Emails>,
|
||||
|
@ -17,9 +18,9 @@ struct Emails {
|
|||
|
||||
fn main() {
|
||||
println!("Preeeeow, world.");
|
||||
let toml_file = fs::read_to_string("src/sbemails.toml")
|
||||
.expect("failed to read sbemails.toml");
|
||||
let sbemails: Sbemails = toml::from_str(&toml_file)
|
||||
let sbemails: Sbemails = toml::from_str(
|
||||
std::str::from_utf8(SBEMAILS_FILE).unwrap()
|
||||
)
|
||||
.expect("failed to deserialize sbemails.toml");
|
||||
let mut random_number = thread_rng();
|
||||
let sbemail = sbemails.emails.choose(&mut random_number).unwrap();
|
||||
|
|
Loading…
Reference in a new issue