fn append_logs(&mut self, new_entries: Vec<LogEntry>, prev_index: u64) {
        let mut idx = self.log_index_to_idx(prev_index + 1);
        let logs = &mut self.logs;
        for new_log in new_entries.into_iter() {
            match logs.get(idx) {
                Some(log) => {
                    if log.term != new_log.term {
                        logs.truncate(idx);
                        logs.push(new_log);
                    }
                }
                None => logs.push(new_log),
            }
            idx += 1;
        }
    }
/// Append new_entries to local logs one by one.
///
/// Start from `prev_index`(exclusive)
Append new_entries to local logs one by one.
Append new_entries to local logs one by one .
fn append_logs(&mut self, new_entries: Vec<LogEntry>, prev_index: u64) {
        let mut idx = self.log_index_to_idx(prev_index + 1);
        let logs = &mut self.logs;
        for new_log in new_entries.into_iter() {
            match logs.get(idx) {
                Some(log) => {
                    if log.term != new_log.term {
                        logs.truncate(idx);
                        logs.push(new_log);
                    }
                }
                None => logs.push(new_log),
            }
            idx += 1;
        }
    }
fn append_logs ( & mut self , new_entries : Vec < LogEntry > , prev_index : u64 ) { let mut idx = self . log_index_to_idx ( prev_index + 1 ) ; let logs = & mut self . logs ; for new_log in new_entries . into_iter ( ) { match logs . get ( idx ) { Some ( log ) => { if log . term != new_log . term { logs . truncate ( idx ) ; logs . push ( new_log ) ; } } None => logs . push ( new_log ) , } idx += 1 ; } }
Append new_entries to local logs one by one.
Append new_entries to local logs one by one .
&mut self
new_entries
Vec<LogEntry>
prev_index
u64
&mut self
new_entries
Vec<LogEntry>
prev_index
u64