Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/topic_partition_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,16 @@ impl TopicPartitionList {
}

/// Creates a new empty list with the specified capacity.
///
/// # Panics
///
/// Panics if `capacity` is greater than `i32::MAX`, since the underlying
/// librdkafka API accepts the capacity as a signed 32-bit integer.
pub fn with_capacity(capacity: usize) -> TopicPartitionList {
assert!(
capacity <= i32::MAX as usize,
"TopicPartitionList capacity exceeds i32::MAX"
);
let ptr = unsafe { rdsys::rd_kafka_topic_partition_list_new(capacity as i32) };
unsafe { TopicPartitionList::from_ptr(ptr) }
}
Expand Down