Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.

Fix wrong comments and add corresponding tests#78

Merged
jplatte merged 8 commits into
jplatte:mainfrom
YichiZhang0613:fix
May 25, 2025
Merged

Fix wrong comments and add corresponding tests#78
jplatte merged 8 commits into
jplatte:mainfrom
YichiZhang0613:fix

Conversation

@YichiZhang0613

Copy link
Copy Markdown

Fix #77 .

@Hywan

Hywan commented May 19, 2025

Copy link
Copy Markdown

Thanks for the patch! Please fix the CI and I'll be happy to approve your changes :-).

@Hywan Hywan self-requested a review May 19, 2025 08:06
Comment thread eyeball-im/src/vector.rs
/// # Panics
///
/// Panics if the capacity is `0`, or larger than `usize::MAX / 2`.
/// Panics if the capacity is `0`, or overflows.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This panic message was copied from https://docs.rs/tokio/latest/tokio/sync/broadcast/fn.channel.html, and I think we should not change.

@YichiZhang0613 YichiZhang0613 May 19, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This panic message was copied from https://docs.rs/tokio/latest/tokio/sync/broadcast/fn.channel.html, and I think we should not change.

But it actually is wrong. As capacity <= usize::MAX / 2, it will still panic(capacity overflows) as I shown in https://github.com/jplatte/eyeball/issues/77. So I think changing it to "Panics if the capacity is 0, or overflows." is more accurate.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure tokio would be interesting in a doc fix too.

@YichiZhang0613 YichiZhang0613 May 21, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if capacity is a large enough number that is less than usize::MAX/2, it will still panic because of capacity overflow, so I think this is an obvious error. The comment should be changed to "Panics if the capacity is 0, or overflows. " in my view.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, the code is here, https://github.com/tokio-rs/tokio/blob/17d8c2b29d94550f504d8fd76d8d8aaf66095864/tokio/src/sync/broadcast.rs#L543-L546, so it's not larger than, but larger or equal to.

I noticed that contributor of tokio has confirmed my issue and make PR in tokio-rs/tokio#7352, could you please merge my PR?

@jplatte jplatte left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc updates are good, but I have some other comments.

Comment thread eyeball-im/src/vector/transaction.rs Outdated
Comment on lines +25 to +26
#[allow(missing_docs)]
pub fn new(inner: &'o mut ObservableVector<T>) -> Self {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be made public.

Comment thread eyeball-im/tests/observable_vec.rs Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this file to tests/it as panic.rs or something like that? You'll also have to add a mod declaration for it in it/main.rs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this file to tests/it as panic.rs or something like that? You'll also have to add a mod declaration for it in it/main.rs.

OK.

Comment thread eyeball-im/tests/observable_vec.rs Outdated
Comment on lines +21 to +22
let mut inner = ObservableVector::default();
let mut txn = ObservableVectorTransaction::new(&mut inner);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut inner = ObservableVector::default();
let mut txn = ObservableVectorTransaction::new(&mut inner);
let mut ob = ObservableVector::default();
let mut txn = ob.transaction();

@jplatte jplatte left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jplatte jplatte merged commit 9c8307c into jplatte:main May 25, 2025
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code Comment Inconsistency

3 participants