File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -2538,14 +2538,15 @@ pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool {
2538
2538
!ptr. is_null ( ) && ptr. is_aligned ( )
2539
2539
}
2540
2540
2541
+ const fn max_len < T > ( ) -> usize {
2542
+ let size = crate :: mem:: size_of :: < T > ( ) ;
2543
+ if size == 0 { usize:: MAX } else { isize:: MAX as usize / size }
2544
+ }
2545
+
2541
2546
/// Checks whether an allocation of `len` instances of `T` exceeds
2542
2547
/// the maximum allowed allocation size.
2543
2548
pub ( crate ) fn is_valid_allocation_size < T > ( len : usize ) -> bool {
2544
- let max_len = const {
2545
- let size = crate :: mem:: size_of :: < T > ( ) ;
2546
- if size == 0 { usize:: MAX } else { isize:: MAX as usize / size }
2547
- } ;
2548
- len <= max_len
2549
+ len <= max_len :: < T > ( )
2549
2550
}
2550
2551
2551
2552
/// Checks whether the regions of memory starting at `src` and `dst` of size
You can’t perform that action at this time.
0 commit comments