zerocopy 0.8.49

Zerocopy makes zero-cost memory manipulation effortless. We write "unsafe" so you don't have to.
Documentation
# Copyright 2018 The Fuchsia Authors
#
# Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
# <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
# license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
# This file may not be copied, modified, or distributed except according to
# those terms.

# Put both crates in a single workspace so that `trybuild` compiler errors have
# paths that are stable regardless of the path to the repository root. This
# avoids issues like:
# https://github.com/dtolnay/trybuild/issues/207#issuecomment-131227.594
[workspace]

[package]
edition = "2021"
name = "zerocopy"
version = "0.8.49"
authors = [
    "Joshua Liebow-Feeser <joshlf@google.com>",
    "Jack Wrenn <jswrenn@amazon.com>",
]
description = "Zerocopy makes zero-cost memory manipulation effortless. We write \"unsafe\" so you don't have to."
categories = [
    "embedded",
    "encoding",
    "no-std::no-alloc",
    "parsing",
    "rust-patterns",
]
keywords = ["cast", "convert", "transmute", "transmutation", "type-punning"]
license = "BSD-2-Clause OR Apache-2.0 OR MIT"
repository = "https://github.com/google/zerocopy"
rust-version = "1.56.0"

exclude = [".*"]

[package.metadata.build-rs]
# These key/value pairs are parsed by `build.rs`. Each entry names a `--cfg`
# which will be emitted if zerocopy is built with a toolchain version *lower*
# than the specified version. In the emitted `--cfg`, dashes are replaced by
# underscores.
#
# Each name is suffixed with the version it corresponds to. This is a convention
# used in the codebase to make it less likely for us to make mistakes when
# writing `doc_cfg` attributes.
#
# It may seem odd to name cfgs `no-zerocopy-foo` and emit these cfgs on
# toolchains lower than that target toolchain. We do this because it is
# friendlier to users who compile zerocopy by directly invoking rustc or by
# invoking rustc from a build system other than Cargo. If such a user provides
# no `--cfg` arguments, then, assuming they are on a sufficiently recent
# toolchain, everything will "just work" without requiring extra configuration.
# See [1] for an example of a user upgrading from a version of zerocopy which
# did things in the inverse way. See #2259 for more context.
#
# [1] https://fuchsia-review.googlesource.com/c/fuchsia/+/1433139/1/third_party/rust_crates/Cargo.toml


# From 1.89.0, Rust supports x86 AVX-12 SIMD types (previously gated by the
# `stdarch_x86_avx512` feature).
no-zerocopy-simd-x86-avx12-1-89-0 = "1.89.0"

# From 1.81.0, Rust supports the `core::error::Error` trait.
no-zerocopy-core-error-1-81-0 = "1.81.0"

# From 1.78.0, Rust supports the `#[diagnostic::on_unimplemented]` attribute.
no-zerocopy-diagnostic-on-unimplemented-1-78-0 = "1.78.0"

# From 1.61.0, Rust supports generic types with trait bounds in `const fn`.
no-zerocopy-generic-bounds-in-const-fn-1-61-0 = "1.61.0"

# From 1.60.0, Rust supports `cfg(target_has_atomics)`, which allows us to
# detect whether a target supports particular sets of atomics.
no-zerocopy-target-has-atomics-1-60-0 = "1.60.0"

# When the "simd" feature is enabled, include SIMD types from the
# `core::arch::aarch64` module, which was stabilized in 1.59.0. On earlier Rust
# versions, these types require the "simd-nightly" feature.
no-zerocopy-aarch64-simd-1-59-0 = "1.59.0"

# Include SIMD types from `core::arch::aarch64` on big endian targets. Prior to
# 1.87.0 (https://github.com/rust-lang/rust/pull/136831) the types were only
# correct on little endian and backed off from stable in a breaking change.
no-zerocopy-aarch64-simd-be-1-87-0 = "1.87.0"

# Permit panicking in `const fn`s and calling `Vec::try_reserve`.
no-zerocopy-panic-in-const-and-vec-try-reserve-1-57-0 = "1.57.0"

[package.metadata.ci]
# The versions of the stable and nightly compiler toolchains to use in CI.
pinned-stable = "1.93.1"
pinned-nightly = "nightly-2026-01-25"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition", "--extend-css", "rustdoc/style.css"]
targets = [
    "x86_64-unknown-linux-gnu",
    "x86_64-apple-darwin",
    "x86_64-pc-windows-msvc",
    "i686-unknown-linux-gnu",
    "i686-pc-windows-msvc"
]

[package.metadata.playground]
features = ["__internal_use_only_features_that_work_on_stable"]

[features]
alloc = []
derive = ["zerocopy-derive"]
simd = []
simd-nightly = ["simd"]
float-nightly = []
std = ["alloc"]
# This feature depends on all other features that work on the stable compiler.
# We make no stability guarantees about this feature; it may be modified or
# removed at any time.
__internal_use_only_features_that_work_on_stable = [
    "alloc",
    "derive",
    "simd",
    "std",
]

[dependencies]
zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive", optional = true }

# The "associated proc macro pattern" ensures that the versions of zerocopy and
# zerocopy-derive remain equal, even if the 'derive' feature isn't used.
# See: https://github.com/matklad/macro-dep-test
[target.'cfg(any())'.dependencies]
zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive" }

[dev-dependencies]
# FIXME(#381) Remove this dependency once we have our own layout gadgets.
elain = "0.3.0"
itertools = "0.11"
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
regex = "1.0"
rustversion = "1.0"
static_assertions = "1.1"
testutil = { path = "testutil" }
# In tests, unlike in production, zerocopy-derive is not optional
zerocopy-derive = { version = "=0.8.49", path = "zerocopy-derive" }