Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 17
---
category: General Utility
description: `vec![]` but for fixed length arrays
msrv: 1.36.0
---
vec![]
but for fixed length arrays
Pros:
Cons:
unsafe
in macro prevents use with #![forbid(unsafe_code)]
- Bumps MSRV on patch versions (but so far only for damn good reasons)
version |
thoroughness |
understanding |
rating |
notes |
1.0.5 |
high |
high |
✔️ positive |
01940637 Protection against evil catch-all traits defining length |
1.0.4 |
high |
high |
❔ neutral |
01940637 #9 MSRV 1.36.0 , MaybeUninit should be safe + sound |
1.0.3 |
high |
high |
❗️ negative |
#9 Good for the time, but core::mem::uninitialized is technically UB |
1.0.2 |
high |
high |
❗️ negative |
#9 Good for the time, but core::mem::uninitialized is technically UB |
1.0.1 |
high |
high |
❗️ negative |
#9 Good for the time, but core::mem::uninitialized is technically UB |
1.0.0 |
high |
high |
❗️ negative |
#9 Good for the time, but core::mem::uninitialized is technically UB |
0.1.2 |
high |
high |
❗️ negative |
#9 Good for the time, but core::mem::uninitialized is technically UB |
Diff |
Rating |
Notes |
src\lib.rs |
✔️ |
Protection from evil, internal comments explaining the awkward code |
tests\test.rs |
✔️ |
Testing protection against evil |
Diff |
Rating |
Notes |
.gitlab-ci.yml |
✔️ |
MSRV 1.25.0 -> 1.36.0 |
src\lib.rs |
✔️ |
uninitialized -> MaybeUninit , moved common code out of macro into crate |
Diff |
Rating |
Notes |
.cargo_vcs_info.json |
✔️ |
|
.gitlab-ci.yml |
✔️ |
MSRV 1.25.0 |
Cargo.toml |
✔️ |
moved repositories, badge |
Cargo.toml.orig |
✔️ |
moved repositories, badge |
README.md |
✔️ |
Removed travis badge |
src\lib.rs |
❗✔️ |
+local_inner_macros , still uses uninitialized |
tests\test.rs |
✔️ |
|
Diff |
Rating |
Notes |
src\lib.rs |
❗✔️ |
#[allow(unsafe_code)] in macro, still uses uninitialized |
tests\test.rs |
✔️ |
eliminated static mut |
Diff |
Rating |
Notes |
src\lib.rs |
❗✔️ |
::array_macros::__core:: -> $crate::__core:: , still uses uninitialized |
Diff |
Rating |
Notes |
src\lib.rs |
❗✔️ |
str -> String , still uses uninitialized |
tests\test.rs |
⚠️✔️ |
Closer scopes, still uses static mut |
Decent for the time. Caveats:
- Doesn't use
$crate::
- Uses
core::mem::uninitialized
(modern code should use MaybeUninit
)
Drop order on panic is "correct" (forward, and only created elements)
Writing vec.position = i
before ptr::write
looks awkward as heck but is correct.
On the first loop iteration, vec.position = i = 0
, so nothing will be dropped if callback(0)
panics.
On the second loop iteration, vec.position = i = 1
, so the previous element will be dropped if callback(1)
panics.
After callback(count-1)
, no panic can occur before the entire array is assumed initialized, ergo skipping vec.position = i = count-1
isn't a problem.
File |
Rating |
Notes |
.cargo-ok |
✔️ |
|
.gitignore |
✔️ |
|
.travis.yml |
✔️ |
MSRV stable |
Cargo.toml |
✔️ |
MIT/Apache-2.0 |
Cargo.toml.orig |
✔️ |
MIT/Apache-2.0 |
LICENSE-APACHE |
✔️ |
Apache-2.0 |
LICENSE-MIT |
✔️ |
MIT |
README.md |
✔️ |
|
src\lib.rs |
❗ |
|
tests\test.rs |
⚠️ |
static mut s could be made atomic for safety |
Other |
Rating |
Notes |
unsafe |
❗ |
uninitialize is technically UB |
fs |
✔️ |
None |
io |
✔️ |
None |
docs |
✔️ |
Good |
tests |
✔️ |
Good |