1
Fork 0

Rollup merge of #110635 - scottmcm:zst-checks, r=the8472

More `IS_ZST` in `library`

I noticed that `post_inc_start` and `pre_dec_end` were doing this check in different ways

d19b64fb54/library/core/src/slice/iter/macros.rs (L76-L93)

so started making this PR, then added a few more I found since I was already making changes anyway.
This commit is contained in:
Yuki Okushi 2023-04-22 10:33:57 +09:00 committed by GitHub
commit 581e7417ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 15 deletions

View file

@ -73,7 +73,7 @@ macro_rules! iterator {
// Unsafe because the offset must not exceed `self.len()`.
#[inline(always)]
unsafe fn post_inc_start(&mut self, offset: usize) -> * $raw_mut T {
if mem::size_of::<T>() == 0 {
if T::IS_ZST {
zst_shrink!(self, offset);
self.ptr.as_ptr()
} else {