Answers for "rust•armanazi•error•[E0369]: binary operation `>=` cannot be applied to type `T`"

0

rust•armanazi•error•[E0369]: binary operation `>=` cannot be applied to type `T`

//Add "PartialOrd +" to follow where
impl<T> Iterator for Stepper<T>
    where T:AddAssign + Copy 
{
    type Item=T;

    fn next(&mut self)->Option<T>{
        if self.curr >= self.stop //[E0369]{
            return None;
        }
        let res = self.curr;
        self.curr += self.step;
        Some(res)
    }
}

//e.g:
impl <T:PartialOrd> Tree<T>{
    pub fn add(&mut self,t:T) {
        match self{
            LeafTail => {
                *self = Tree::new(t);
            },
            Head(d,lt,rt)=>{
                if t < *d {
                    lt.add(t);
                }else {
                    rt.add(t);
                }
            }
        }
    }
    pub fn LeafTail()->Self{
        LeafTail
    }

    pub fn new(t:T)->Self{
        Head(t,Box::new(LeafTail),Box::new(LeafTail))
    }

}
Posted by: Guest on March-17-2022

Code answers related to "rust•armanazi•error•[E0369]: binary operation `>=` cannot be applied to type `T`"

Browse Popular Code Answers by Language