Antti / rust-amqp

AMQP client in pure rust. Corresponds to rabbitmq spec.
MIT License
249 stars 45 forks source link

impl Consumer for unboxed closure and Box<Consumer> #55

Closed ryansname closed 7 years ago

ryansname commented 7 years ago

Hey, I wanted to be able to loop over a list of consumers and add them to a basic_consume, this pull request allows that. There were a few breaking changes but (to me) they seem to allow more flexibility.

Breaking change: Removal of ConsumerCallBackFn The impl Consumer for ConsumerCallBackFn is covered by the changed impl<F> Consumer for F where F: FnMut(...) Breaking change: Removal of the box wrapper around the existing FnMut impl for Consumer. This was required for the blanket impl of all boxed consumers, removing the box has also allowed passing in of the closure directly, which is nice for usability. Possible Breaking Change: I've had to add the 'static lifetime to the impl<F> Consumer for F where F: FnMut(...). I'm not confident enough to say this will not break something, but since basic_consume requires Consumer + 'static I guess that this would be safe.

Antti commented 7 years ago

Looks good. Thank you!