Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active October 16, 2024 19:54
Show Gist options
  • Save dacr/93556bf4ef3f7de5f0025ca91f0ea8cd to your computer and use it in GitHub Desktop.
Save dacr/93556bf4ef3f7de5f0025ca91f0ea8cd to your computer and use it in GitHub Desktop.
rust hello scripts dependencies / published by https://github.com/dacr/code-examples-manager #ac971a3b-eec9-4488-acdf-9ea642ffdf77/e7b2f6c86872e79081f5d60b81560c800fed5f53
#!/usr/bin/env rust-script
// cargo-deps : rand="0.8.0", chrono="0.4"
// summary : rust hello scripts dependencies
// keywords : rust, dependencies, @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 : ac971a3b-eec9-4488-acdf-9ea642ffdf77
// created-on : 2024-10-12T20:43:43+02:00
// 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