Coverage Report

Created: 2025-12-05 07:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/zerocopy-0.8.31/src/pointer/mod.rs
Line
Count
Source
1
// Copyright 2023 The Fuchsia Authors
2
//
3
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6
// This file may not be copied, modified, or distributed except according to
7
// those terms.
8
9
//! Abstractions over raw pointers.
10
11
mod inner;
12
#[doc(hidden)]
13
pub mod invariant;
14
mod ptr;
15
mod transmute;
16
17
#[doc(hidden)]
18
pub use {inner::PtrInner, transmute::*};
19
#[doc(hidden)]
20
pub use {
21
    invariant::{BecauseExclusive, BecauseImmutable, Read},
22
    ptr::Ptr,
23
};
24
25
/// A shorthand for a maybe-valid, maybe-aligned reference. Used as the argument
26
/// to [`TryFromBytes::is_bit_valid`].
27
///
28
/// [`TryFromBytes::is_bit_valid`]: crate::TryFromBytes::is_bit_valid
29
pub type Maybe<'a, T, Aliasing = invariant::Shared, Alignment = invariant::Unaligned> =
30
    Ptr<'a, T, (Aliasing, Alignment, invariant::Initialized)>;
31
32
/// Checks if the referent is zeroed.
33
0
pub(crate) fn is_zeroed<T, I>(ptr: Ptr<'_, T, I>) -> bool
34
0
where
35
0
    T: crate::Immutable + crate::KnownLayout,
36
0
    I: invariant::Invariants<Validity = invariant::Initialized>,
37
0
    I::Aliasing: invariant::Reference,
38
{
39
0
    ptr.as_bytes::<BecauseImmutable>().as_ref().iter().all(|&byte| byte == 0)
40
0
}