Created
November 10, 2023 23:41
-
-
Save dacr/3129c2bac94c0b86724d3c50191de065 to your computer and use it in GitHub Desktop.
rust first example script / published by https://github.com/dacr/code-examples-manager #cdb91a18-e4b3-4430-a708-7e341a4cb5ef/c399f79ff8a4725077cc11edda1b1721327789d0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env rust-script | |
// cargo-deps: rand="0.8.0", chrono="0.4" | |
// summary : rust first example script | |
// keywords : rust, hello-world, @testable | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : cdb91a18-e4b3-4430-a708-7e341a4cb5ef | |
// created-on : 2023-11-11T15:23:31.602Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : ./$file | |
use rand::prelude::*; | |
use chrono::{DateTime, Utc}; | |
fn main() { | |
let x:u64 = random(); | |
let ts:DateTime<Utc> = Utc::now(); | |
let msg = if x % 2 == 0 { | |
"Hello world" | |
} else { | |
"Good bye world" | |
}; | |
println!("{} {}", ts, msg); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment