This repository was archived by the owner on Apr 28, 2025. It is now read-only.
Commit 5dea7fc
committed
Split
There is a difference in intent between wishing to cast and truncate the
value, and expecting the input to be within range. To make this clear,
add separate `cast_lossy` and `cast_from_lossy` to indicate what that
truncation is intended, leaving `cast` and `cast_from` to only be casts
that expected not to truncate.
Actually enforcing this at runtime is likely to have a cost, so just
`debug_assert!` that `cast` doesn't truncate.cast into cast and cast_lossy
1 parent edc5958 commit 5dea7fc
1 file changed
+19
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
346 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
347 | 351 | | |
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
| 355 | + | |
351 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
352 | 360 | | |
353 | 361 | | |
354 | 362 | | |
355 | 363 | | |
356 | 364 | | |
357 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
358 | 370 | | |
359 | 371 | | |
360 | 372 | | |
| |||
364 | 376 | | |
365 | 377 | | |
366 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
367 | 386 | | |
368 | 387 | | |
369 | 388 | | |
| |||
0 commit comments