After some formatting and adding imports
use chrono::DateTime;
use chrono::Local;
use chrono::Utc;
use num::NumCast;
use std::collections::HashMap;
use std::fmt::Display;
use std::marker::PhantomData;
use std::sync::Arc;
use std::sync::Mutex;
#[derive(Debug, Clone)]
//This my struct
pub struct GlobalExpiredTime<'ph, T: NumCast, V, P: ?Sized>
where
P: 'ph + std::marker::Send,
V: num_traits::ToPrimitive,
T: num_traits::ToPrimitive + num_traits::NumCast,
{
//First- time of entry in block (Local or UTC)
//Second- key: (for example simply) number of block (or associated name)
// value: time count (on whether it was done in threads or simply run the same block twise, thrice, fourfold etc.)
//(Option- maybe you don't want to take it into account, then counted time on this=0)
LBlockT: Arc<Mutex<Vec<DateTime<Local>>>>, // u32- count times
IntInfo: HashMap<T, (V, Option<u32>)>, //Int- intilligence (mark it)
BlLife: PhantomData<&'ph P>,
}
//For example:
impl<'ph, K, V, P> GlobalExpiredTime<'ph, K, V, P>
where
//K must be the number! of block in program counted times.(as example)
//Default- zero, ToPrimitive + std::cmp::Ord- requirement NumCast::from, Send- to use in threads
K: std::default::Default
+ num_traits::NumCast
+ num_traits::ToPrimitive
+ Copy
+ Sync
+ std::cmp::Ord
+ std::fmt::Debug, //, TimeSpec:
V: Sync
+ std::fmt::Debug
+ Clone
+ Display
+ num_traits::NumCast
+ num_traits::ToPrimitive
+ std::cmp::Ord,
P: std::marker::Send,
{
fn new(t_kind: Option<String>) -> Self {
if let Some(kind_of_time) = t_kind {
if kind_of_time.to_uppercase() == "UTC" {
let now: DateTime<Utc> = Utc::now();
println!("UTC now is: {}, so you had instantiated time in program TBC_eq(TransferBurguerCorrection_eq)", now.to_rfc2822());
} else if kind_of_time.to_uppercase() == "LOCAL" {
//How impl |"LOC" ... etc?
let now: DateTime<Local> = Local::now();
println!("Local time now is: {}, so you had instantiated time in program TBC_eq(TransferBurguerCorrection_eq)", now.to_rfc2822());
}
}
//Now only create fields and push them in structs
let mut date_vec = Vec::<DateTime<Local>>::new();
date_vec.push(Local::now());
let LBlockT = Arc::new(Mutex::new(date_vec));
let IntInfo = HashMap::new();
Self {
LBlockT, //equiv LBlockT: LBlockT
IntInfo, //because we know only start point- no other info to push
BlLife: PhantomData,
}
}
}
fn main() {
//....
let mut time: GlobalExpiredTime<'_, u32, i32, i32> =
GlobalExpiredTime::new(Some("UTC".to_owned()));
}
it does compile if you replace GlobalExpiredTime<u32, (i32, i32)>
with GlobalExpiredTime<u32, i32, i32>
.
The important error message was
error[E0107]: wrong number of type arguments: expected 3, found 2
--> src/main.rs:75:19
|
75 | let mut time: GlobalExpiredTime<u32, (i32, i32)> =
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 type arguments
Unless this isn’t what you meant and you want to use (i32, i32)
as a numeric type (which it really isn’t; that’s why you get the other error message).
Note that I haven’t tried to understand the actual code yet, so it might still not behave as intended. (But getting it to compile is probably a good first step.)