We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 581aa8d commit 47f60d7Copy full SHA for 47f60d7
core/src/fmt/num.rs
@@ -88,8 +88,9 @@ unsafe trait GenericRadix: Sized {
88
};
89
}
90
91
- // SAFETY: `curr` is initialized to `buf.len()` and is only decremented,
92
- // so it is always in bounds.
+ // SAFETY: `curr` is initialized to `buf.len()` and is only decremented, so it can't overflow. It is
+ // decremented exactly once for each digit. Since u128 is the widest fixed width integer format dupported,
93
+ // the maximum number of digits (bits) is 128 for base-2, so `curr` won't underflow as well.
94
let buf = unsafe { buf.get_unchecked(curr..) };
95
// SAFETY: The only chars in `buf` are created by `Self::digit` which are assumed to be
96
// valid UTF-8
0 commit comments