pub(crate) fn next_safe<T>(&self, goal: T, turn_to_learner: bool) -> Result<Self, NodeIdNotInNodes<C>>
    where T: Into<EitherNodesOrIds<C>> {
        let goal: EitherNodesOrIds<C> = goal.into();

        let goal_ids = goal.node_ids();

        let new_configs = if self.configs.contains(&goal_ids) {
            vec![goal_ids]
        } else {
            vec![self.configs.last().cloned().unwrap(), goal_ids]
        };

        let mut new_learners = self.all_learners().clone();

        if turn_to_learner {
            // Add all members as learners.
            // The learners that are already a member will be filtered out in Self::new()
            new_learners.append(&mut self.all_members());
        };

        let new_nodes = Self::extend_nodes(self.nodes.clone(), &goal.nodes());

        let m = Membership::new(new_configs, Some(new_learners));
        let res = m.set_nodes(new_nodes)?;
        Ok(res)
    }
/// Returns the next safe membership to change to while the expected final membership is `goal`.
///
/// E.g.(`cicj` is a joint membership of `ci` and `cj`):
/// - `c1.next_step(c1)` returns `c1`
/// - `c1.next_step(c2)` returns `c1*c2`
/// - `c1c2.next_step(c2)` returns `c2`
/// - `c1c2.next_step(c1)` returns `c1`
/// - `c1c2.next_step(c3)` returns `c2c3`
///
/// With this method the membership change algo is simplified to:
/// ```ignore
/// while curr != goal {
///     let next = curr.next_step(goal);
///     change_membership(next);
///     curr = next;
/// }
/// ```
Returns the next safe membership to change to while the expected final membership is `goal`.


Returns the next safe membership to change to while the expected final membership is ` goal ` .
pub(crate) fn next_safe<T>(&self, goal: T, turn_to_learner: bool) -> Result<Self, NodeIdNotInNodes<C>>
    where T: Into<EitherNodesOrIds<C>> {
        let goal: EitherNodesOrIds<C> = goal.into();
        let goal_ids = goal.node_ids();
        let new_configs = if self.configs.contains(&goal_ids) {
            vec![goal_ids]
        } else {
            vec![self.configs.last().cloned().unwrap(), goal_ids]
        };
        let mut new_learners = self.all_learners().clone();
        if turn_to_learner {
            // Add all members as learners.
            // The learners that are already a member will be filtered out in Self::new()
            new_learners.append(&mut self.all_members());
        };
        let new_nodes = Self::extend_nodes(self.nodes.clone(), &goal.nodes());
        let m = Membership::new(new_configs, Some(new_learners));
        let res = m.set_nodes(new_nodes)?;
        Ok(res)
    }
pub ( crate ) fn next_safe < T > ( & self , goal : T , turn_to_learner : bool ) -> Result < Self , NodeIdNotInNodes < C > > where T : Into < EitherNodesOrIds < C > > { let goal : EitherNodesOrIds < C > = goal . into ( ) ; let goal_ids = goal . node_ids ( ) ; let new_configs = if self . configs . contains ( & goal_ids ) { vec ! [ goal_ids ] } else { vec ! [ self configs last ( ) cloned ( ) unwrap ( ) goal_ids ] } ; let mut new_learners = self . all_learners ( ) . clone ( ) ; if turn_to_learner { // Add all members as learners. // The learners that are already a member will be filtered out in Self::new() new_learners . append ( & mut self . all_members ( ) ) ; } ; let new_nodes = Self :: extend_nodes ( self . nodes . clone ( ) , & goal . nodes ( ) ) ; let m = Membership :: new ( new_configs , Some ( new_learners ) ) ; let res = m . set_nodes ( new_nodes ) ? ; Ok ( res ) }
Returns the next safe membership to change to while the expected final membership is `goal`.
Returns the next safe membership to change to while the expected final membership is ` goal ` .
&self
goal
T
turn_to_learner
bool