Use vec![] for instantiate an empty vector in nonempty! macro#69
Use vec![] for instantiate an empty vector in nonempty! macro#69greyblake wants to merge 1 commit intocloudhead:masterfrom
Conversation
|
Thanks for the contribution! @nuttycom would |
|
|
|
Hmmm, I am not sure here. I think the existing use of `vec` may actually
be a bug, I just didn’t notice it because there there are no uses of the
`nonempty` macro in a context where no-std is enforced and not
automatically enabled.
`vec!` itself is part of `std`:
https://doc.rust-lang.org/std/macro.vec.html
So it could be that you can’t use the macro in a no-std context, but
because it’s a macro if it’s never used there is no problem.
What is probably needed to demonstrate the issue is a CI task like the one
I added here:
zcash/orchard#450 but with the generated lib.rs file containing some code that invokes the `nonempty` macro.
I'm not sure what the best way to make sure that `extern crate alloc` is added to the generated code is, though.
…On Mon, Jan 6, 2025 at 8:18 PM Serhii Potapov ***@***.***> wrote:
@FintanH <https://github.com/FintanH>
vec![] is already used in another branch of the macro, so I would assume
it does not make it worse :D
image.png (view on web)
<https://github.com/user-attachments/assets/1acb9b23-78dd-4daf-8b89-b61ccadac33d>
—
Reply to this email directly, view it on GitHub
<#69 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAGXR3Q6OZKCU7KUAWHZC32JLCHVAVCNFSM6AAAAABUB3IE6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZTGY2TSMJYGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
It is actually part of It looks like it requires a #![no_std]
#[macro_use]
extern crate alloc;
fn main() {
vec![0];
} |
|
Ok, so afaiu this change is fine because the |
|
@FintanH Thanks! |
|
Resolved in #70 |

It fixes #68
I hope using
vec![]should not be a big problem, causevec![]is already used in another branch of the macro.Thank you again for you work!