I got error for the below, calls in statics are limited to constant functions, tuple structs and tuple variants
I have 2 questions:
1: how to declare module level Instant type variable?
2: as_millis() return u128, is it ok to do as u32 here?
use std::time::{Duration, Instant};
use std::thread::sleep;
static refTime: Instant = Instant::now();
fn currentMs() -> u32 {
refTime.elapsed().as_millis() as u32
}
fn main() {
// let now = Instant::now();
sleep(Duration::new(2, 0));
println!("{}", currentMs() );
}