pub fn describe<T: AckedIndexer>(&self, l: &T) -> String {
        if self.votes.is_empty() {
            return "<empty majority quorum>".to_string();
        }

        #[derive(Default, Clone, Copy)]
        struct Tup {
            id: u64,
            idx: Index,
            // idx found?
            ok: bool,
            // length of bar displayed for this up
            bar: usize,
        }

        // Below, populate .bar so that the i-th largest commit index has bar i (we
        // plot this as sort of a progress bar). The actual code is a bit more
        // complicated and also makes sure that equal index => equal bar.
        let n = self.votes.len();
        let mut info: Vec<Tup> = vec![Tup::default()].repeat(n);
        for (i, id) in self.iter().enumerate() {
            let idx = l.acked_index(id);
            info[i].id = *id;
            info[i].idx = *idx.or_else(|| Some(&0)).unwrap();
            info[i].ok = idx.is_some();
        }
        // sort by index
        info.sort_by(|a, b| {
            if a.idx == b.idx {
                a.id.cmp(&b.id)
            } else {
                a.idx.cmp(&b.idx)
            }
        });

        // Populate .bar.
        for i in 0..info.len() {
            if i > 0 && info[i - 1].idx < info[i].idx {
                info[i].bar = i;
            }
        }

        // sort by id
        info.sort_by(|a, b| a.id.cmp(&b.id));

        let mut buf = String::new();
        // print

        buf.write_str((" ".repeat(n) + "    idx\n").as_str())
            .unwrap();

        for i in 0..info.len() {
            let bar = info[i].bar;
            if !info[i].ok {
                buf.write_str("?").unwrap();
                buf.write_str(" ".repeat(n).as_str()).unwrap();
            } else {
                buf.write_str(&*("x".repeat(bar) + ">" + " ".repeat(n - bar).as_str()))
                    .unwrap();
            }
            buf.write_str(format!(" {:>5}    (id={})\n", info[i].idx, info[i].id).as_str())
                .unwrap();
        }
        buf
    }
/// returns a (multi-line) representation of the commit indexes for the
/// given lookuper.
returns a (multi-line) representation of the commit indexes for the
given lookuper.
returns a ( multi - line ) representation of the commit indexes for the given lookuper .
pub fn describe<T: AckedIndexer>(&self, l: &T) -> String {
        if self.votes.is_empty() {
            return "<empty majority quorum>".to_string();
        }
        #[derive(Default, Clone, Copy)]
        struct Tup {
            id: u64,
            idx: Index,
            // idx found?
            ok: bool,
            // length of bar displayed for this up
            bar: usize,
        }
        // Below, populate .bar so that the i-th largest commit index has bar i (we
        // plot this as sort of a progress bar). The actual code is a bit more
        // complicated and also makes sure that equal index => equal bar.
        let n = self.votes.len();
        let mut info: Vec<Tup> = vec![Tup::default()].repeat(n);
        for (i, id) in self.iter().enumerate() {
            let idx = l.acked_index(id);
            info[i].id = *id;
            info[i].idx = *idx.or_else(|| Some(&0)).unwrap();
            info[i].ok = idx.is_some();
        }
        // sort by index
        info.sort_by(|a, b| {
            if a.idx == b.idx {
                a.id.cmp(&b.id)
            } else {
                a.idx.cmp(&b.idx)
            }
        });
        // Populate .bar.
        for i in 0..info.len() {
            if i > 0 && info[i - 1].idx < info[i].idx {
                info[i].bar = i;
            }
        }
        // sort by id
        info.sort_by(|a, b| a.id.cmp(&b.id));
        let mut buf = String::new();
        // print
        buf.write_str((" ".repeat(n) + "    idx\n").as_str())
            .unwrap();
        for i in 0..info.len() {
            let bar = info[i].bar;
            if !info[i].ok {
                buf.write_str("?").unwrap();
                buf.write_str(" ".repeat(n).as_str()).unwrap();
            } else {
                buf.write_str(&*("x".repeat(bar) + ">" + " ".repeat(n - bar).as_str()))
                    .unwrap();
            }
            buf.write_str(format!(" {:>5}    (id={})\n", info[i].idx, info[i].id).as_str())
                .unwrap();
        }
        buf
    }
pub fn describe < T : AckedIndexer > ( & self , l : & T ) -> String { if self . votes . is_empty ( ) { return " " . to_string ( ) ; } # [ derive ( Default Clone Copy ) ] struct Tup { id : u64 , idx : Index , // idx found? ok : bool , // length of bar displayed for this up bar : usize , } // Below, populate .bar so that the i-th largest commit index has bar i (we // plot this as sort of a progress bar). The actual code is a bit more // complicated and also makes sure that equal index => equal bar. let n = self . votes . len ( ) ; let mut info : Vec < Tup > = vec ! [ Tup default ( ) ] . repeat ( n ) ; for ( i , id ) in self . iter ( ) . enumerate ( ) { let idx = l . acked_index ( id ) ; info [ i ] . id = * id ; info [ i ] . idx = * idx . or_else ( | | Some ( & 0 ) ) . unwrap ( ) ; info [ i ] . ok = idx . is_some ( ) ; } // sort by index info . sort_by ( | a , b | { if a . idx == b . idx { a . id . cmp ( & b . id ) } else { a . idx . cmp ( & b . idx ) } } ) ; // Populate .bar. for i in 0 .. info . len ( ) { if i > 0 && info [ i - 1 ] . idx < info [ i ] . idx { info [ i ] . bar = i ; } } // sort by id info . sort_by ( | a , b | a . id . cmp ( & b . id ) ) ; let mut buf = String :: new ( ) ; // print buf . write_str ( ( " " . repeat ( n ) + " \n " ) . as_str ( ) ) . unwrap ( ) ; for i in 0 .. info . len ( ) { let bar = info [ i ] . bar ; if ! info [ i ] . ok { buf . write_str ( " " ) . unwrap ( ) ; buf . write_str ( " " . repeat ( n ) . as_str ( ) ) . unwrap ( ) ; } else { buf . write_str ( & * ( " " . repeat ( bar ) + " " + " " . repeat ( n - bar ) . as_str ( ) ) ) . unwrap ( ) ; } buf . write_str ( format ! ( " \n " info [ i ] idx info [ i ] id ) . as_str ( ) ) . unwrap ( ) ; } buf }
returns a (multi-line) representation of the commit indexes for the
given lookuper.
returns a ( multi - line ) representation of the commit indexes for the given lookuper .
&self
l
&T