Expand description
Safe arithmetic operations with overflow detection.
This module provides traits and functions for performing arithmetic operations that detect overflow and return errors instead of panicking or wrapping.
§Security
Arithmetic overflow in filesystem code can lead to serious security vulnerabilities like buffer overflows. Always use these checked operations when computing sizes, offsets, or counts from untrusted metadata.
Traits§
- Checked
Ops - Trait for checked arithmetic operations.
- Checked
Slice Ops - Extension trait for checked slice operations.
Functions§
- align_
down - Aligns a value down to the given alignment.
- align_
up - Aligns a value up to the given alignment.
- div_
ceil - Computes ceil(a / b) without overflow.
- saturating_
div - Saturating divide that returns 0 for division by zero.