use std::io; use std::ops::Add; use rust_decimal::prelude::ToPrimitive; use time::OffsetDateTime; #[derive(Debug)] struct OrderInfo { id: String, sell_price: f64, time_num: i64 } fn add_aa(x: &mut i64) -> Result{ let mut i:i64 = OffsetDateTime::now_utc().unix_timestamp(); if i < 0{ println!("1231"); *x = i; Ok(0) } else { Err(io::Error::new(io::ErrorKind::Other, "错了")) } } #[tokio::test] async fn test(){ // let mut now_time = OffsetDateTime::now_utc().unix_timestamp(); // let mut last_time = now_time; // while true { // if(now_time < last_time + 5){ // now_time = OffsetDateTime::now_utc().unix_timestamp(); // }else{ // last_time = now_time+5; // println!("30s 后:{}", now_time); // return; // } // } let mut x: i64 = 64; let f = match add_aa(&mut x) { Ok(m) => m, Err(error) => { 1 }, }; println!("f: {}", f); }