Skip to content

Commit 9f3cac0

Browse files
committed
Merge branch 'main' into pr/oligamiq/123
2 parents 402fce3 + 44a58e2 commit 9f3cac0

File tree

7 files changed

+69
-42
lines changed

7 files changed

+69
-42
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6-
## [Unreleased]
6+
## [Unreleased
7+
### Changed
8+
- Updated optional dependencies to latest versions:
9+
* `zercopy` 0.6 -> 0.8
10+
11+
### Added
12+
- Added support for `arbitrary` crate. Fixes [#110]. By [@FL33TW00D].
13+
14+
### Fixed
15+
- Suppressed unexpected_cfg lint warnings on newer versions of stable Rust.
716

817
## [2.4.1] - 2024-04-06 <a name="2.4.1"></a>
918
### Fixed
@@ -330,6 +339,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
330339
[#100]: https://github.com/starkat99/half-rs/issues/100
331340
[#103]: https://github.com/starkat99/half-rs/issues/103
332341
[#107]: https://github.com/starkat99/half-rs/issues/107
342+
[#110]: https://github.com/starkat99/half-rs/issues/110
333343

334344
[@tspiteri]: https://github.com/tspiteri
335345
[@PSeitz]: https://github.com/PSeitz
@@ -351,6 +361,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
351361
[@wx-csy]: https://github.com/wx-csy
352362
[@eiz]: https://github.com/eiz
353363
[@comath]: https://github.com/comath
364+
[@FL33TW00D]: https://github.com/FL33TW00D
354365

355366

356367
[Unreleased]: https://github.com/starkat99/half-rs/compare/v2.4.1...HEAD

Cargo.lock

Lines changed: 25 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ std = ["alloc"]
1919
use-intrinsics = [] # Deprecated
2020
alloc = []
2121
rand_distr = ["dep:rand", "dep:rand_distr"]
22+
arbitrary = ["dep:arbitrary"]
2223

2324
[dependencies]
2425
cfg-if = "1.0.0"
@@ -31,12 +32,15 @@ serde = { version = "1.0", default-features = false, features = [
3132
num-traits = { version = "0.2.14", default-features = false, features = [
3233
"libm",
3334
], optional = true }
34-
zerocopy = { version = "0.6.0", default-features = false, optional = true }
35+
zerocopy = { version = "0.8", default-features = false, features = [
36+
"derive",
37+
], optional = true }
3538
rand = { version = "0.9.0", default-features = false, features = [
3639
"thread_rng",
3740
], optional = true }
3841
rand_distr = { version = "0.5.0", default-features = false, optional = true }
3942
rkyv = { version = "0.7", optional = true }
43+
arbitrary = { version = "1.3.2", features = ["derive"], optional = true }
4044

4145
[target.'cfg(target_arch = "spirv")'.dependencies]
4246
crunchy = "0.2.2"

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ See the [crate documentation](https://docs.rs/half/) for more details.
4444
- **`bytemuck`** — Enable `Zeroable` and `Pod` trait implementations from the
4545
[`bytemuck`](https://crates.io/crates/bytemuck) crate.
4646

47-
- **`zerocopy`** — Enable `AsBytes` and `FromBytes` trait implementations from the
47+
- **`zerocopy`** — Enable `IntoBytes` and `FromBytes` trait implementations from the
4848
[`zerocopy`](https://crates.io/crates/zerocopy) crate.
4949

5050
- **`rand_distr`** — Enable sampling from distributions like `Uniform` and `Normal` from the
5151
[`rand_distr`](https://crates.io/crates/rand_distr) crate.
5252

5353
- **`rkyv`** -- Enable zero-copy deserializtion with [`rkyv`](https://crates.io/crates/rkyv) crate.
5454

55+
- **`aribtrary`** -- Enable fuzzing support with [`arbitrary`](https://crates.io/crates/arbitrary)
56+
crate by implementing `Arbitrary` trait.
57+
5558
### Hardware support
5659

5760
The following list details hardware support for floating point types in this crate. When using `std`

src/bfloat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::{
2020
#[cfg(feature = "serde")]
2121
use serde::{Deserialize, Serialize};
2222
#[cfg(feature = "zerocopy")]
23-
use zerocopy::{AsBytes, FromBytes};
23+
use zerocopy::{FromBytes, IntoBytes};
2424

2525
pub(crate) mod convert;
2626

@@ -42,7 +42,7 @@ pub(crate) mod convert;
4242
)]
4343
#[cfg_attr(feature = "rkyv", archive(resolver = "Bf16Resolver"))]
4444
#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))]
45-
#[cfg_attr(feature = "zerocopy", derive(AsBytes, FromBytes))]
45+
#[cfg_attr(feature = "zerocopy", derive(IntoBytes, FromBytes))]
4646
#[cfg_attr(kani, derive(kani::Arbitrary))]
4747
pub struct bf16(u16);
4848

src/binary16.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::{
2020
#[cfg(feature = "serde")]
2121
use serde::{Deserialize, Serialize};
2222
#[cfg(feature = "zerocopy")]
23-
use zerocopy::{AsBytes, FromBytes};
23+
use zerocopy::{FromBytes, IntoBytes};
2424

2525
pub(crate) mod arch;
2626

@@ -41,8 +41,9 @@ pub(crate) mod arch;
4141
)]
4242
#[cfg_attr(feature = "rkyv", archive(resolver = "F16Resolver"))]
4343
#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))]
44-
#[cfg_attr(feature = "zerocopy", derive(AsBytes, FromBytes))]
44+
#[cfg_attr(feature = "zerocopy", derive(IntoBytes, FromBytes))]
4545
#[cfg_attr(kani, derive(kani::Arbitrary))]
46+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
4647
pub struct f16(u16);
4748

4849
impl f16 {

src/lib.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,17 @@
9494
//! - **`bytemuck`** — Adds support for the [`bytemuck`] crate by implementing [`Zeroable`] and
9595
//! [`Pod`] traits for both [`f16`] and [`bf16`].
9696
//!
97-
//! - **`zerocopy`** — Adds support for the [`zerocopy`] crate by implementing [`AsBytes`] and
97+
//! - **`zerocopy`** — Adds support for the [`zerocopy`] crate by implementing [`IntoBytes`] and
9898
//! [`FromBytes`] traits for both [`f16`] and [`bf16`].
9999
//!
100100
//! - **`rand_distr`** — Adds support for the [`rand_distr`] crate by implementing [`Distribution`]
101101
//! and other traits for both [`f16`] and [`bf16`].
102102
//!
103103
//! - **`rkyv`** -- Enable zero-copy deserializtion with [`rkyv`] crate.
104104
//!
105+
//! - **`aribtrary`** -- Enable fuzzing support with [`arbitrary`] crate by implementing
106+
//! [`Arbitrary`] trait.
107+
//!
105108
//! [`alloc`]: https://doc.rust-lang.org/alloc/
106109
//! [`std`]: https://doc.rust-lang.org/std/
107110
//! [`binary16`]: https://en.wikipedia.org/wiki/Half-precision_floating-point_format
@@ -112,6 +115,7 @@
112115
//! [`zerocopy`]: https://crates.io/crates/zerocopy
113116
//! [`rand_distr`]: https://crates.io/crates/rand_distr
114117
//! [`rkyv`]: (https://crates.io/crates/rkyv)
118+
//! [`arbitrary`]: (https://crates.io/crates/arbitrary)
115119
#![cfg_attr(
116120
feature = "alloc",
117121
doc = "
@@ -172,13 +176,13 @@
172176
#![cfg_attr(
173177
feature = "zerocopy",
174178
doc = "
175-
[`AsBytes`]: zerocopy::AsBytes
179+
[`IntoBytes`]: zerocopy::IntoBytes
176180
[`FromBytes`]: zerocopy::FromBytes"
177181
)]
178182
#![cfg_attr(
179183
not(feature = "zerocopy"),
180184
doc = "
181-
[`AsBytes`]: https://docs.rs/zerocopy/*/zerocopy/trait.AsBytes.html
185+
[`IntoBytes`]: https://docs.rs/zerocopy/*/zerocopy/trait.IntoBytes.html
182186
[`FromBytes`]: https://docs.rs/zerocopy/*/zerocopy/trait.FromBytes.html"
183187
)]
184188
#![cfg_attr(
@@ -191,14 +195,24 @@
191195
doc = "
192196
[`Distribution`]: https://docs.rs/rand/*/rand/distributions/trait.Distribution.html"
193197
)]
198+
#![cfg_attr(
199+
feature = "arbitrary",
200+
doc = "
201+
[`Arbitrary`]: arbitrary::Arbitrary"
202+
)]
203+
#![cfg_attr(
204+
not(feature = "arbitrary"),
205+
doc = "
206+
[`Arbitrary`]: https://docs.rs/arbitrary/*/arbitrary/trait.Arbitrary.html"
207+
)]
194208
#![warn(
195209
missing_docs,
196210
missing_copy_implementations,
197211
trivial_numeric_casts,
198212
future_incompatible
199213
)]
200214
#![cfg_attr(not(target_arch = "spirv"), warn(missing_debug_implementations))]
201-
#![allow(clippy::verbose_bit_mask, clippy::cast_lossless)]
215+
#![allow(clippy::verbose_bit_mask, clippy::cast_lossless, unexpected_cfgs)]
202216
#![cfg_attr(not(feature = "std"), no_std)]
203217
#![doc(html_root_url = "https://docs.rs/half/2.4.1")]
204218
#![doc(test(attr(deny(warnings), allow(unused))))]

0 commit comments

Comments
 (0)