Unchecked requirements
In karyon-master/core/src/event.rs, following comment indicates this function should be panic when size = 0 while it actually will not.
/// If `size` is zero, this function will panic.
pub fn with_buffer_size(size: usize) -> Arc<EventEmitter<T>> {
Arc::new(Self {
listeners: Mutex::new(HashMap::new()),
listener_buffer_size: size,
})
}
In karyon-master/core/src/pubsub.rs, this function has the same issue.
/// If `size` is zero, this function will panic.
pub fn with_buffer_size(size: usize) -> Arc<Publisher<T>> {
Arc::new(Self {
subs: Mutex::new(HashMap::new()),
subscription_buffer_size: size,
})
}
So I think assert_ne!(size, 0); should be appended for each function.
Hello @YichiZhang0613
Thanks for mentioning this. I'm actually in the process of moving event.rs to a separate crate. You can check out this PR #28 . I just pushed a patch that adds the zero assertion for that function.
Thanks for mentioning this. I'm actually in the process of moving event.rs to a separate crate. You can check out this PR #28 . I just pushed a patch that adds the zero assertion for that function.
OK.
Hello @YichiZhang0613
Thanks for mentioning this. I'm actually in the process of moving event.rs to a separate crate. You can check out this PR #28 . I just pushed a patch that adds the zero assertion for that function.
Hi, I noticed that assert_ne!(size, 0); was added for with_buffer_size(size: usize) -> Arc<EventEmitter<T>>, but not yet for with_buffer_size in karyon-master/core/src/pubsub.rs yet. I fixed it in #33.