From ab684c82146a4004cd2f6420b84bebdec5939347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81owicki?= Date: Thu, 29 Jun 2023 19:31:40 +0200 Subject: [PATCH] review --- src/producer/base_producer.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/producer/base_producer.rs b/src/producer/base_producer.rs index 6ffa0d41a..59f4f7e79 100644 --- a/src/producer/base_producer.rs +++ b/src/producer/base_producer.rs @@ -234,12 +234,10 @@ unsafe extern "C" fn partitioner_cb> let producer_context = &mut *(rkt_opaque as *mut C); - match producer_context.get_custom_partitioner() { - None => panic!("custom partitioner is not set"), - Some(partitioner) => { - partitioner.partition(topic_name, key, partition_cnt, is_partition_available) - } - } + producer_context + .get_custom_partitioner() + .expect("custom partitioner is not set") + .partition(topic_name, key, partition_cnt, is_partition_available) } impl FromClientConfig for BaseProducer { @@ -266,7 +264,7 @@ where let native_config = config.create_native_config()?; let context = Arc::new(context); - if let Some(_) = context.get_custom_partitioner() { + if context.get_custom_partitioner().is_some() { let default_topic_config = unsafe { rdsys::rd_kafka_conf_get_default_topic_conf(native_config.ptr()) }; unsafe {