Commit cf96416
committed
hybrid-array: make
It's used when checking the lengths of slices match an array size prior
to using a pointer cast to convert types.
If someone were to make their own `typenum::Unsigned` type and impl
`ArraySize` for it with an `ArrayType` whose size does not match
`Unsigned::USIZE`, that would be UB.
Really `ArraySize` is not intended for downstream crates to impl anyway,
but making it an `unsafe trait` at least captures the UB potential.
Additionally this adds more debug checks to `check_slice_length` to
ensure that if there is a length mismatch, it's at least caught in debug
builds.ArraySize an unsafe trait
1 parent 14b1e13 commit cf96416
1 file changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
308 | 311 | | |
309 | 312 | | |
310 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
311 | 317 | | |
312 | 318 | | |
313 | 319 | | |
| |||
400 | 406 | | |
401 | 407 | | |
402 | 408 | | |
403 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
404 | 420 | | |
405 | 421 | | |
406 | 422 | | |
| |||
457 | 473 | | |
458 | 474 | | |
459 | 475 | | |
460 | | - | |
| 476 | + | |
461 | 477 | | |
462 | 478 | | |
463 | 479 | | |
| |||
0 commit comments