Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove array-macro dependency #253

Merged
merged 1 commit into from
Oct 2, 2021

Conversation

KamilaBorowska
Copy link
Contributor

Hello, I'm a maintainer of array-macro crate.

Code that was using array_macro::array! used it incorrectly causing a subtle issue. In 2.0.0 the behaviour of array macro did change to clone values to match the behavior of standard library's vec! macro.

In the code that used this macro it was used for objects of PhysBuf type.

#[derive(Clone)]
pub struct PhysBuf {
    buf: Arc<Mutex<Vec<u8>>>,
}

For Arc objects cloning doesn't create a new object, rather it shares a reference causing a subtle issue where all elements of rx_buffers shared the exact same buffer, which I don't think you have intended.

Standard library now contains array::map which can replace array_macro::array! in most situations. It may be a good idea to use that, considering amount of people that look at standard library's code is greater than number of people that look at array_macro (which is just me).

@vinc
Copy link
Owner

vinc commented Oct 2, 2021

Wow I didn't notice the issue but with your explanation it's very clear, thanks a lot 👍

@vinc vinc merged commit 07075dc into vinc:trunk Oct 2, 2021
@vinc vinc mentioned this pull request Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants