File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 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 {
25382538 !ptr. is_null ( ) && ptr. is_aligned ( )
25392539}
25402540
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+
25412546/// Checks whether an allocation of `len` instances of `T` exceeds
25422547/// the maximum allowed allocation size.
25432548pub ( 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 > ( )
25492550}
25502551
25512552/// 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