Closed
Description
Hi,
I tried using your crate like in the example in the documentation
const MY_RANDOM_BYTES: [u8; 32] = const_random!([u8; 32]);
That will panic with a message "invalid type". The underlying problem is in the parsing code in this line
byte_array: &str if byte_array.starts_with("[u8 ; ") && byte_array.ends_with(']')=> ...
Here you are sensitive to spaces and the formatting is problematic if someone has rustfmt enabled like I do. I could submit a PR to fix this, but rather than just patching that particular line I would want to use the syn
crate to parse the tokens correctly. I don't know if you would want this dependency though, so I thought I'd ask. Your code works when I use
#[rustfmt::skip]
const MY_RANDOM_BYTES: [u8; 32] = const_random!([u8 ; 32]);
which seems a bit silly :)
Metadata
Metadata
Assignees
Labels
No labels