use std::thread;
use std::time::Duration;
use chrono::Local;
pub fn start_quotes() {
let quotes: &'static [&'static str] = &[
"Make America Great Again!",
"You're fired!",
"I will build a great wall—and nobody builds walls better than me.",
"Promises made, promises kept.",
"We will restore law and order.",
"We will drain the swamp.",
"America First.",
"The forgotten men and women of our country will be forgotten no longer.",
"We will win so much, you may even get tired of winning.",
"Jobs, jobs, jobs!",
];
let mut idx = 0usize;
thread::Builder::new()
.name("trump-quotes".to_string())
.spawn(move || {
loop {
let q = quotes[idx % quotes.len()];
println!("[{}] {}", Local::now().format("%Y-%m-%d %H:%M:%S"), q);
idx = idx.wrapping_add(1);
thread::sleep(Duration::from_secs(10));
}
})
.expect("failed to spawn trump quotes thread");
}
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}