brew install mkcert
mkcert -install
use chrono; | |
use chrono::offset::TimeZone; | |
let birth_date = chrono::Utc.from_local_date(&chrono::NaiveDate::parse_from_str("1995-07-05", "%Y-%m-%d")).unwrap(); | |
let duration_since_birth = chrono::Utc::today().signed_duration_since(birth_date); | |
let age = duration_since_birth.num_days() / 365 |
fn main() { | |
let mut v: Vec<(&str, i32)> = vec![("a", 2), ("b", 1), ("c", 3)]; | |
v.sort_by(|a, b| a.1.cmp(&b.1)); // increasing order | |
v.sort_by(|a, b| b.1.cmp(&a.1)); // decreasing order | |
println!("{:?}", v); | |
} |