common: instruction: relax InstructionCollector trait bounds
This commit is contained in:
parent
b3a6d08656
commit
62851bbd60
@ -46,9 +46,7 @@ pub struct InstructionCollector<I,T>{
|
|||||||
time:T,
|
time:T,
|
||||||
instruction:Option<I>,
|
instruction:Option<I>,
|
||||||
}
|
}
|
||||||
impl<I,T> InstructionCollector<I,T>
|
impl<I,T> InstructionCollector<I,T>{
|
||||||
where T:Copy+PartialOrd,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(time:T)->Self{
|
pub const fn new(time:T)->Self{
|
||||||
Self{
|
Self{
|
||||||
@ -57,19 +55,6 @@ impl<I,T> InstructionCollector<I,T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn time(&self)->T{
|
|
||||||
self.time
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn collect(&mut self,instruction:Option<TimedInstruction<I,T>>){
|
|
||||||
if let Some(ins)=instruction{
|
|
||||||
if ins.time<self.time{
|
|
||||||
self.time=ins.time;
|
|
||||||
self.instruction=Some(ins.instruction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn take(self)->Option<TimedInstruction<I,T>>{
|
pub fn take(self)->Option<TimedInstruction<I,T>>{
|
||||||
//STEAL INSTRUCTION AND DESTROY INSTRUCTIONCOLLECTOR
|
//STEAL INSTRUCTION AND DESTROY INSTRUCTIONCOLLECTOR
|
||||||
self.instruction.map(|instruction|TimedInstruction{
|
self.instruction.map(|instruction|TimedInstruction{
|
||||||
@ -78,3 +63,20 @@ impl<I,T> InstructionCollector<I,T>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl<I,T:Copy> InstructionCollector<I,T>{
|
||||||
|
#[inline]
|
||||||
|
pub const fn time(&self)->T{
|
||||||
|
self.time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<I,T:PartialOrd> InstructionCollector<I,T>{
|
||||||
|
#[inline]
|
||||||
|
pub fn collect(&mut self,instruction:Option<TimedInstruction<I,T>>){
|
||||||
|
if let Some(ins)=instruction{
|
||||||
|
if ins.time<self.time{
|
||||||
|
self.time=ins.time;
|
||||||
|
self.instruction=Some(ins.instruction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user