mirror of
https://codeberg.org/takouhai/strongbad_email.git
synced 2024-12-22 03:20:36 -05:00
fix: load directly from file
This commit is contained in:
parent
ab14bfd267
commit
b98a118d82
1 changed files with 4 additions and 7 deletions
11
src/main.rs
11
src/main.rs
|
@ -3,14 +3,12 @@ use rand::thread_rng;
|
|||
use serde::Deserialize;
|
||||
use toml;
|
||||
|
||||
static SBEMAILS_FILE: &'static[u8] = include_bytes!("sbemails.toml");
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
struct Sbemails {
|
||||
emails: Vec<Emails>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize)]
|
||||
struct Emails {
|
||||
number: u8,
|
||||
title: String,
|
||||
|
@ -18,9 +16,8 @@ struct Emails {
|
|||
|
||||
fn main() {
|
||||
println!("Preeeeow, world.");
|
||||
let sbemails: Sbemails = toml::from_str(
|
||||
std::str::from_utf8(SBEMAILS_FILE).unwrap()
|
||||
)
|
||||
let the_paper = include_str!("sbemails.toml");
|
||||
let sbemails: Sbemails = toml::from_str(the_paper)
|
||||
.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