Make Step::extend_with must_use.

This commit is contained in:
Andreas Fackler 2018-12-11 12:59:54 +01:00 committed by Andreas Fackler
parent 7677f6343c
commit ee99aad266
4 changed files with 6 additions and 9 deletions

View File

@ -439,7 +439,7 @@ fn main() {
.build_with_transactions(txs.clone(), rng)
.expect("instantiate QueueingHoneyBadger");
let (sq, mut step) = SenderQueue::builder(qhb, peer_ids.into_iter()).build(our_id);
step.extend_with(qhb_step, Message::from);
assert!(step.extend_with(qhb_step, Message::from).is_empty());
(sq, step)
};

View File

@ -117,10 +117,7 @@ where
}
/// Creates a new Queueing Honey Badger instance with an empty buffer.
pub fn build<R: Rng>(self, rng: &mut R) -> Result<QueueingHoneyBadgerWithStep<T, N, Q>>
where
R: 'static + Rng + Send + Sync,
{
pub fn build<R: Rng>(self, rng: &mut R) -> Result<QueueingHoneyBadgerWithStep<T, N, Q>> {
self.build_with_transactions(None, rng)
}

View File

@ -114,6 +114,7 @@ impl<M, O, N> Step<M, O, N> {
}
/// Extends `self` with `other`s messages and fault logs, and returns `other.output`.
#[must_use]
pub fn extend_with<M2, O2, FM>(&mut self, other: Step<M2, O2, N>, f_msg: FM) -> Vec<O2>
where
FM: Fn(M2) -> M,

View File

@ -164,9 +164,8 @@ where
let mut rng = rand::thread_rng().gen::<Isaac64Rng>();
let (qhb, qhb_step) =
QueueingHoneyBadger::builder_joining(our_id, secret_key, join_plan, &mut rng)
.expect("failed to rebuild the node with a join plan")
.batch_size(3)
.build(&mut rng);
.and_then(|builder| builder.batch_size(3).build(&mut rng))
.expect("failed to rebuild the node with a join plan");
let (sq, mut sq_step) = SenderQueue::builder(qhb, peer_ids.into_iter()).build(our_id);
*node.instance_mut() = sq;
sq_step.extend(qhb_step.map(|output| output, Message::from));
@ -193,7 +192,7 @@ fn new_queueing_hb(
.build(&mut rng)
.expect("failed to build QueueingHoneyBadger");
let (sq, mut step) = SenderQueue::builder(qhb, peer_ids).build(our_id);
step.extend(qhb_step.map(|output| output, Message::from));
assert!(step.extend_with(qhb_step, Message::from).is_empty());
(sq, step)
}