pub fn task<F: 'static>(mut self, name: I, coro: F) -> Self
    where
        F: FnMut() -> Pause<I, T>
    {
        let idx = if self.tasks.len() > 0 {
            let mut top = self.tasks.len() - 1;
            let mut bottom = 0;
            loop {
                let i = top + bottom >> 1;
                match self.tasks[i].name.cmp(&name) {
                    Ordering::Equal => {
                        // a corner case; if we already have it,
                        // just update the coroutine
                        self.tasks[i].coro = Coroutine::new(coro);
                        return self;
                    },
                    Ordering::Greater => bottom = i + 1,
                    Ordering::Less => if i == 0 {
                        break i
                    } else {
                        top = i - 1
                    },
                }
                if bottom > top {
                    break bottom
                }
            }
        } else {
            0
        };
        self.tasks.insert(idx, Task {
            name,
            coro: Coroutine::new(coro),
        });
        self
    }
/// Adds a task with the given name and coroutine.
Adds a task with the given name and coroutine.
Adds a task with the given name and coroutine .
pub fn task<F: 'static>(mut self, name: I, coro: F) -> Self
    where
        F: FnMut() -> Pause<I, T>
    {
        let idx = if self.tasks.len() > 0 {
            let mut top = self.tasks.len() - 1;
            let mut bottom = 0;
            loop {
                let i = top + bottom >> 1;
                match self.tasks[i].name.cmp(&name) {
                    Ordering::Equal => {
                        // a corner case; if we already have it,
                        // just update the coroutine
                        self.tasks[i].coro = Coroutine::new(coro);
                        return self;
                    },
                    Ordering::Greater => bottom = i + 1,
                    Ordering::Less => if i == 0 {
                        break i
                    } else {
                        top = i - 1
                    },
                }
                if bottom > top {
                    break bottom
                }
            }
        } else {
            0
        };
        self.tasks.insert(idx, Task {
            name,
            coro: Coroutine::new(coro),
        });
        self
    }
pub fn task < F : ' static > ( mut self , name : I , coro : F ) -> Self where F : FnMut ( ) -> Pause < I , T > { let idx = if self . tasks . len ( ) > 0 { let mut top = self . tasks . len ( ) - 1 ; let mut bottom = 0 ; loop { let i = top + bottom >> 1 ; match self . tasks [ i ] . name . cmp ( & name ) { Ordering :: Equal => { // a corner case; if we already have it, // just update the coroutine self . tasks [ i ] . coro = Coroutine :: new ( coro ) ; return self ; } , Ordering :: Greater => bottom = i + 1 , Ordering :: Less => if i == 0 { break i } else { top = i - 1 } , } if bottom > top { break bottom } } } else { 0 } ; self . tasks . insert ( idx , Task { name , coro : Coroutine :: new ( coro ) , } ) ; self }
Adds a task with the given name and coroutine.
Adds a task with the given name and coroutine .
mut self
name
I
coro
F
mut self
name
I
coro
F