Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:26
Show Gist options
  • Select an option

  • Save dacr/93556bf4ef3f7de5f0025ca91f0ea8cd to your computer and use it in GitHub Desktop.

Select an option

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/361c528110e777c61b7fb667f450d2df1b4fe06a
#!/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 License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// 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