Skip to content

Commit

Permalink
[error] Implement std::error::Error on errors
Browse files Browse the repository at this point in the history
While we're here, also relax `Dispaly for AlignmentError<Src, Dst>` to
permit `Dst: ?Sized` in exchange for `Dst: KnownLayout`. This is an
important relaxation since our APIs permit performing conversions into
unsized destination types with runtime alignment checking.

Also make all errors `Send + Sync` regardless of `Dst`, which only
exists at the type level, but is never instantiated.

Finally, make `Display`'s verbosity conditional on `debug_assertions`.

Makes progress on #1297

Co-authored-by: John Wrenn <jswrenn@amazon.com>
  • Loading branch information
joshlf and jswrenn committed Jun 24, 2024
1 parent 1bf5d4a commit 9155b18
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 50 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ alloc = []
derive = ["zerocopy-derive"]
simd = []
simd-nightly = ["simd"]
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"]
__internal_use_only_features_that_work_on_stable = ["alloc", "derive", "simd", "std"]

[dependencies]
zerocopy-derive = { version = "=0.8.0-alpha.14", path = "zerocopy-derive", optional = true }
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ for network parsing.
the `alloc` crate is added as a dependency, and some allocation-related
functionality is added.

- **`std`**
By default, `zerocopy` is `no_std`. When the `std` feature is enabled, the
`std` crate is added as a dependency (ie, `no_std` is disabled), and
support for some `std` types is added. `std` implies `alloc`.

- **`derive`**
Provides derives for the core marker traits via the `zerocopy-derive`
crate. These derives are re-exported from `zerocopy`, so it is not
Expand Down
Loading

0 comments on commit 9155b18

Please sign in to comment.