From e6eab9d4b0bcbec23c5f7c5cb42ec1a1ba8a0a30 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Thu, 1 Apr 2021 16:51:38 -0700 Subject: Upgrade rust/crates/half to 1.7.1 Test: make Change-Id: I1dea5f4c5a7e654f7cdd98e2ef6890fce61a0bbe --- .cargo_vcs_info.json | 2 +- .travis.yml | 50 ----------------- CHANGELOG.md | 23 +++++++- Cargo.toml | 16 +++++- Cargo.toml.orig | 16 +++++- METADATA | 10 ++-- README.md | 7 ++- TEST_MAPPING | 16 +++--- appveyor.yml | 156 --------------------------------------------------- src/bfloat.rs | 106 +++++++++++++++++++++++++++++++++- src/binary16.rs | 106 +++++++++++++++++++++++++++++++++- src/lib.rs | 7 ++- 12 files changed, 284 insertions(+), 231 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index a35bc0b..4c10491 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "04b83b7c1954e3c0659a027179ba144b90559e19" + "sha1": "4476873652bf25676f0610764b0f14a2f5d2ce62" } } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cbf87db..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -os: - - linux - - windows -sudo: false -language: rust -rust: - - stable - - beta - - nightly -matrix: - include: - - rust: stable - env: CARGOFLAGS="--features serde" - - rust: stable - env: CARGOFLAGS="--features std" - - rust: stable - env: CARGOFLAGS="--features std,serde" - - rust: stable - env: CARGOFLAGS="--features alloc" - - rust: nightly - env: CARGOFLAGS=--all-features - - - rust: stable - os: windows - env: CARGOFLAGS="--features serde" - - rust: stable - os: windows - env: CARGOFLAGS="--features std" - - rust: stable - os: windows - env: CARGOFLAGS="--features alloc" - - rust: stable - os: windows - env: CARGOFLAGS="--features std,serde" - - rust: nightly - os: windows - env: CARGOFLAGS=--all-features - - - rust: 1.32.0 - script: - - cargo update - - cargo update -p unicode-normalization --precise 0.1.9 - - cargo update -p criterion --precise 0.3.0 - - cargo test --features std -branches: - except: - - gh-pages -script: - - cargo build --verbose --all-targets $CARGOFLAGS - - cargo test --verbose $CARGOFLAGS diff --git a/CHANGELOG.md b/CHANGELOG.md index 3488747..490cb6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.7.1] - 2021-01-17 +### Fixed +- Docs.rs now generates docs for `bytemuck` and `num-traits` optional features. + +## [1.7.0] - 2021-01-17 +### Added +- Added optional implementations of `bytemuck` traits `Zeroable` and `Pod` under `bytemuck` cargo + feature. By [@charles-r-earp]. +- Added optional implementations of `num-traits` traits `ToPrimitive` and `FromPrimitive` under + `num-traits` cargo feature. By [@charles-r-earp]. +- Added implementations of `Binary`, `Octal`, `LowerHex`, and `UpperHex` string format traits to + format raw `f16`/`bf16` bytes to string. + +### Changed +- `Debug` trait implementation now formats `f16`/`bf16` as float instead of raw bytes hex. Use newly + implemented formatting traits to format in hex instead of `Debug`. Fixes [#37]. + ## [1.6.0] - 2020-05-09 ### Added @@ -145,6 +162,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [#16]: https://github.com/starkat99/half-rs/issues/16 [#23]: https://github.com/starkat99/half-rs/issues/23 [#24]: https://github.com/starkat99/half-rs/issues/24 +[#37]: https://github.com/starkat99/half-rs/issues/37 [@tspiteri]: https://github.com/tspiteri [@PSeitz]: https://github.com/PSeitz @@ -153,9 +171,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [@jfrimmel]: https://github.com/jfrimmel [@zserik]: https://github.com/zserik [@bzm3r]: https://github.com/bzm3r +[@charles-r-earp]: https://github.com/charles-r-earp -[Unreleased]: https://github.com/starkat99/half-rs/compare/v1.6.0...HEAD +[Unreleased]: https://github.com/starkat99/half-rs/compare/v1.7.1...HEAD +[1.7.1]: https://github.com/starkat99/half-rs/compare/v1.7.0...v1.7.1 +[1.7.0]: https://github.com/starkat99/half-rs/compare/v1.6.0...v1.7.0 [1.6.0]: https://github.com/starkat99/half-rs/compare/v1.5.0...v1.6.0 [1.5.0]: https://github.com/starkat99/half-rs/compare/v1.4.1...v1.5.0 [1.4.1]: https://github.com/starkat99/half-rs/compare/v1.4.0...v1.4.1 diff --git a/Cargo.toml b/Cargo.toml index c122803..73f965d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,9 @@ [package] edition = "2018" name = "half" -version = "1.6.0" +version = "1.7.1" authors = ["Kathryn Long "] +exclude = ["/ci", "/*.yml"] description = "Half-precision floating point f16 and bf16 types for Rust implementing the IEEE 754-2008 standard binary16 and bfloat16 types." readme = "README.md" keywords = ["f16", "bfloat16", "no_std"] @@ -22,11 +23,22 @@ categories = ["no-std", "data-structures", "encoding"] license = "MIT/Apache-2.0" repository = "https://github.com/starkat99/half-rs" [package.metadata.docs.rs] -features = ["std", "serde"] +features = ["std", "serde", "bytemuck", "num-traits"] [[bench]] name = "convert" harness = false +[dependencies.bytemuck] +version = "1.4.1" +features = ["derive"] +optional = true +default-features = false + +[dependencies.num-traits] +version = "0.2.14" +optional = true +default-features = false + [dependencies.serde] version = "1.0" features = ["derive"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 5fa235f..5963bae 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "half" -version = "1.6.0" # Remember to keep in sync with html_root_url crate attribute +version = "1.7.1" # Remember to keep in sync with html_root_url crate attribute authors = ["Kathryn Long "] description = "Half-precision floating point f16 and bf16 types for Rust implementing the IEEE 754-2008 standard binary16 and bfloat16 types." repository = "https://github.com/starkat99/half-rs" @@ -9,6 +9,7 @@ keywords = ["f16", "bfloat16", "no_std"] license = "MIT/Apache-2.0" categories = ["no-std", "data-structures", "encoding"] edition = "2018" +exclude = ["/ci", "/*.yml"] [badges] appveyor = { repository = "starkat99/half-rs" } @@ -21,14 +22,25 @@ use-intrinsics = [] serialize = ["serde"] # Deprecated. Use serde directly. alloc = [] +[dependencies.bytemuck] +version = "1.4.1" +optional = true +default-features = false +features = ["derive"] + [dependencies.serde] version = "1.0" optional = true default-features = false features = ["derive"] +[dependencies.num-traits] +version = "0.2.14" +optional = true +default-features = false + [package.metadata.docs.rs] -features = ["std", "serde"] +features = ["std", "serde", "bytemuck", "num-traits"] [dev-dependencies] criterion = "0.3" diff --git a/METADATA b/METADATA index 4d8192e..f66d855 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/half/half-1.6.0.crate" + value: "https://static.crates.io/crates/half/half-1.7.1.crate" } - version: "1.6.0" + version: "1.7.1" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 12 - day: 21 + year: 2021 + month: 4 + day: 1 } } diff --git a/README.md b/README.md index 8de9417..c6afe22 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ minimal floating point storage and most major hardware does not implement them, This crate provides [`no_std`](https://rust-embedded.github.io/book/intro/no-std.html) support by default so can easily be used in embedded code where a smaller float format is most useful. -*Requries Rust 1.32 or greater.* If you need support for older versions of Rust, use versions 1.3 and earlier of this crate. +*Requires Rust 1.32 or greater.* If you need support for older versions of Rust, use versions 1.3 and earlier of this crate. See the [crate documentation](https://docs.rs/half/) for more details. @@ -36,6 +36,11 @@ not have hardware support. **Available only on Rust nightly channel.** Enabling the `std` feature enables runtime CPU feature detection when the `use-intrsincis` feature is also enabled. Without this feature detection, intrinsics are only used when compiler host target supports them. +- **`num-traits`** - Enable `ToPrimitive` and `FromPrimitive` trait implementations from the + `num-traits` crate. + +- **`bytemuck`** - Enable `Zeroable` and `Pod` trait implementations from the `bytemuck` crate. + ### More Documentation - [Crate API Reference](https://docs.rs/half/) diff --git a/TEST_MAPPING b/TEST_MAPPING index d5f5785..7f5d34a 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -2,16 +2,13 @@ { "presubmit": [ { - "name": "serde_cbor_device_test_src_lib" - }, - { - "name": "serde_cbor_device_test_tests_value" + "name": "serde_cbor_device_test_tests_std_types" }, { - "name": "serde_cbor_device_test_tests_de" + "name": "serde_cbor_device_test_tests_enum" }, { - "name": "serde_cbor_device_test_tests_bennofs" + "name": "serde_cbor_device_test_tests_value" }, { "name": "serde_cbor_device_test_tests_canonical" @@ -19,14 +16,17 @@ { "name": "serde_cbor_device_test_tests_ser" }, + { + "name": "serde_cbor_device_test_tests_bennofs" + }, { "name": "serde_cbor_device_test_tests_tags" }, { - "name": "serde_cbor_device_test_tests_enum" + "name": "serde_cbor_device_test_tests_de" }, { - "name": "serde_cbor_device_test_tests_std_types" + "name": "serde_cbor_device_test_src_lib" } ] } diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5147453..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,156 +0,0 @@ -# Appveyor configuration template for Rust using rustup for Rust installation -# https://github.com/starkat99/appveyor-rust - -branches: - except: - - gh-pages - -## Operating System (VM environment) ## - -# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets. -os: Visual Studio 2015 - -## Build Matrix ## - -# This configuration will setup a build for each channel & target combination (12 windows -# combinations in all). -# -# There are 3 channels: stable, beta, and nightly. -# -# Alternatively, the full version may be specified for the channel to build using that specific -# version (e.g. channel: 1.5.0) -# -# The values for target are the set of windows Rust build targets. Each value is of the form -# -# ARCH-pc-windows-TOOLCHAIN -# -# Where ARCH is the target architecture, either x86_64 or i686, and TOOLCHAIN is the linker -# toolchain to use, either msvc or gnu. See https://www.rust-lang.org/downloads.html#win-foot for -# a description of the toolchain differences. -# See https://github.com/rust-lang-nursery/rustup.rs/#toolchain-specification for description of -# toolchains and host triples. -# -# Comment out channel/target combos you do not wish to build in CI. -# -# You may use the `cargoflags` and `RUSTFLAGS` variables to set additional flags for cargo commands -# and rustc, respectively. For instance, you can uncomment the cargoflags lines in the nightly -# channels to enable unstable features when building for nightly. Or you could add additional -# matrix entries to test different combinations of features. -environment: - matrix: - ### MSVC Toolchains ### - - # Stable 64-bit MSVC - - channel: stable - target: x86_64-pc-windows-msvc - # Stable 32-bit MSVC - - channel: stable - target: i686-pc-windows-msvc - # Stable 64-bit MSVC w/ optional features - - channel: stable - target: x86_64-pc-windows-msvc - cargoflags: --features "std serde" - # Stable 64-bit MSVC w/ optional features - - channel: stable - target: x86_64-pc-windows-msvc - cargoflags: --features "alloc" - # Stable 32-bit MSVC w/ optional features - - channel: stable - target: i686-pc-windows-msvc - cargoflags: --features "std serde" - # Stable 32-bit MSVC w/ optional features - - channel: stable - target: i686-pc-windows-msvc - cargoflags: --features "alloc" - # Beta 64-bit MSVC - - channel: beta - target: x86_64-pc-windows-msvc - # Beta 32-bit MSVC - - channel: beta - target: i686-pc-windows-msvc - # Nightly 64-bit MSVC w/ nightly features - - channel: nightly - target: x86_64-pc-windows-msvc - cargoflags: --features "use-intrinsics" - # Nightly 32-bit MSVC w/ nightly features - - channel: nightly - target: i686-pc-windows-msvc - cargoflags: --features "use-intrinsics" - - ### GNU Toolchains ### - - # Stable 64-bit GNU - - channel: stable - target: x86_64-pc-windows-gnu - # Stable 32-bit GNU - - channel: stable - target: i686-pc-windows-gnu - # Stable 64-bit GNU w/ optional features - - channel: stable - target: x86_64-pc-windows-gnu - cargoflags: --features "std serde" - # Stable 64-bit GNU w/ optional features - - channel: stable - target: x86_64-pc-windows-gnu - cargoflags: --features "alloc" - # Stable 32-bit GNU w/ optional features - - channel: stable - target: i686-pc-windows-gnu - cargoflags: --features "std serde" - # Stable 32-bit GNU w/ optional features - - channel: stable - target: i686-pc-windows-gnu - cargoflags: --features "alloc" - # Beta 64-bit GNU - - channel: beta - target: x86_64-pc-windows-gnu - # Beta 32-bit GNU - - channel: beta - target: i686-pc-windows-gnu - # Nightly 64-bit GNU w/ nightly features - - channel: nightly - target: x86_64-pc-windows-gnu - cargoflags: --features "use-intrinsics" - # Nightly 32-bit GNU w/ nightly features - - channel: nightly - target: i686-pc-windows-gnu - cargoflags: --features "use-intrinsics" - -### Allowed failures ### - -# See Appveyor documentation for specific details. In short, place any channel or targets you wish -# to allow build failures on (usually nightly at least is a wise choice). This will prevent a build -# or test failure in the matching channels/targets from failing the entire build. -#matrix: -# allow_failures: -# - channel: nightly - -# If you only care about stable channel build failures, uncomment the following line: -#- channel: beta - -## Install Script ## - -# This is the most important part of the Appveyor configuration. This installs the version of Rust -# specified by the 'channel' and 'target' environment variables from the build matrix. This uses -# rustup to install Rust. -# -# For simple configurations, instead of using the build matrix, you can simply set the -# default-toolchain and default-host manually here. -install: - - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init -yv --default-toolchain %channel% --default-host %target% - - set PATH=%PATH%;%USERPROFILE%\.cargo\bin - - rustc -vV - - cargo -vV - -## Build Script ## - -# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents -# the "directory does not contain a project or solution file" error. -build: false - -# Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs -#directly or perform other testing commands. Rust will automatically be placed in the PATH -# environment variable. -test_script: - - cargo test --verbose %cargoflags% diff --git a/src/bfloat.rs b/src/bfloat.rs index 09ad035..8d659f7 100644 --- a/src/bfloat.rs +++ b/src/bfloat.rs @@ -1,9 +1,14 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +#[cfg(feature = "bytemuck")] +use bytemuck::{Pod, Zeroable}; + use core::{ cmp::Ordering, - fmt::{Debug, Display, Error, Formatter, LowerExp, UpperExp}, + fmt::{ + Binary, Debug, Display, Error, Formatter, LowerExp, LowerHex, Octal, UpperExp, UpperHex, + }, num::{FpCategory, ParseFloatError}, str::FromStr, }; @@ -28,6 +33,7 @@ pub(crate) mod convert; #[derive(Clone, Copy, Default)] #[repr(transparent)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))] pub struct bf16(u16); impl bf16 { @@ -593,7 +599,7 @@ impl FromStr for bf16 { impl Debug for bf16 { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { - write!(f, "0x{:X}", self.0) + write!(f, "{:?}", self.to_f32()) } } @@ -615,6 +621,102 @@ impl UpperExp for bf16 { } } +impl Binary for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:b}", self.0) + } +} + +impl Octal for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:o}", self.0) + } +} + +impl LowerHex for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:x}", self.0) + } +} + +impl UpperHex for bf16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:X}", self.0) + } +} + +#[cfg(feature = "num-traits")] +mod impl_num_traits { + use super::bf16; + use num_traits::{FromPrimitive, ToPrimitive}; + + impl ToPrimitive for bf16 { + fn to_i64(&self) -> Option { + Self::to_f32(*self).to_i64() + } + fn to_u64(&self) -> Option { + Self::to_f32(*self).to_u64() + } + fn to_i8(&self) -> Option { + Self::to_f32(*self).to_i8() + } + fn to_u8(&self) -> Option { + Self::to_f32(*self).to_u8() + } + fn to_i16(&self) -> Option { + Self::to_f32(*self).to_i16() + } + fn to_u16(&self) -> Option { + Self::to_f32(*self).to_u16() + } + fn to_i32(&self) -> Option { + Self::to_f32(*self).to_i32() + } + fn to_u32(&self) -> Option { + Self::to_f32(*self).to_u32() + } + fn to_f32(&self) -> Option { + Some(Self::to_f32(*self)) + } + fn to_f64(&self) -> Option { + Some(Self::to_f64(*self)) + } + } + + impl FromPrimitive for bf16 { + fn from_i64(n: i64) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u64(n: u64) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_i8(n: i8) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u8(n: u8) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_i16(n: i16) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u16(n: u16) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_i32(n: i32) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u32(n: u32) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_f32(n: f32) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_f64(n: f64) -> Option { + n.to_f64().map(|x| Self::from_f64(x)) + } + } +} + #[allow( clippy::cognitive_complexity, clippy::float_cmp, diff --git a/src/binary16.rs b/src/binary16.rs index d5164f0..59ef1dc 100644 --- a/src/binary16.rs +++ b/src/binary16.rs @@ -1,9 +1,14 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +#[cfg(feature = "bytemuck")] +use bytemuck::{Pod, Zeroable}; + use core::{ cmp::Ordering, - fmt::{Debug, Display, Error, Formatter, LowerExp, UpperExp}, + fmt::{ + Binary, Debug, Display, Error, Formatter, LowerExp, LowerHex, Octal, UpperExp, UpperHex, + }, num::{FpCategory, ParseFloatError}, str::FromStr, }; @@ -25,8 +30,81 @@ pub(crate) mod convert; #[derive(Clone, Copy, Default)] #[repr(transparent)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))] pub struct f16(u16); +#[cfg(feature = "num-traits")] +mod impl_num_traits { + use super::f16; + use num_traits::{FromPrimitive, ToPrimitive}; + + impl ToPrimitive for f16 { + fn to_i64(&self) -> Option { + Self::to_f32(*self).to_i64() + } + fn to_u64(&self) -> Option { + Self::to_f32(*self).to_u64() + } + fn to_i8(&self) -> Option { + Self::to_f32(*self).to_i8() + } + fn to_u8(&self) -> Option { + Self::to_f32(*self).to_u8() + } + fn to_i16(&self) -> Option { + Self::to_f32(*self).to_i16() + } + fn to_u16(&self) -> Option { + Self::to_f32(*self).to_u16() + } + fn to_i32(&self) -> Option { + Self::to_f32(*self).to_i32() + } + fn to_u32(&self) -> Option { + Self::to_f32(*self).to_u32() + } + fn to_f32(&self) -> Option { + Some(Self::to_f32(*self)) + } + fn to_f64(&self) -> Option { + Some(Self::to_f64(*self)) + } + } + + impl FromPrimitive for f16 { + fn from_i64(n: i64) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u64(n: u64) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_i8(n: i8) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u8(n: u8) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_i16(n: i16) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u16(n: u16) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_i32(n: i32) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_u32(n: u32) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_f32(n: f32) -> Option { + n.to_f32().map(|x| Self::from_f32(x)) + } + fn from_f64(n: f64) -> Option { + n.to_f64().map(|x| Self::from_f64(x)) + } + } +} + #[deprecated( since = "1.4.0", note = "all constants moved to associated constants of [`f16`](../struct.f16.html)" @@ -830,7 +908,7 @@ impl FromStr for f16 { impl Debug for f16 { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { - write!(f, "0x{:X}", self.0) + write!(f, "{:?}", self.to_f32()) } } @@ -852,6 +930,30 @@ impl UpperExp for f16 { } } +impl Binary for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:b}", self.0) + } +} + +impl Octal for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:o}", self.0) + } +} + +impl LowerHex for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:x}", self.0) + } +} + +impl UpperHex for f16 { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{:X}", self.0) + } +} + #[allow( clippy::cognitive_complexity, clippy::float_cmp, diff --git a/src/lib.rs b/src/lib.rs index de35758..3f24662 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,9 @@ //! //! Support for [`serde`] crate `Serialize` and `Deserialize` traits is provided when the `serde` //! feature is enabled. This adds a dependency on [`serde`] crate so is an optional cargo feature. +//! Support for [`bytemuck`] crate `Zeroable` and `Pod` traits is provided with the `bytemuck` +//! feature. Support for the [`num-traits`] crate `ToPrimitive` and `FromPrimitive` traits is +//! provided with the `num-traits` feature. //! //! The crate uses `#[no_std]` by default, so can be used in embedded environments without using the //! Rust `std` library. A `std` feature is available, which enables additional utilities using the @@ -43,6 +46,8 @@ //! [`slice`]: slice/index.html //! [`prelude`]: prelude/index.html //! [`serde`]: https://crates.io/crates/serde +//! [`bytemuck`]: https://crates.io/crates/bytemuck +//! [`num-traits`]: https://crates.io/crates/num-traits //! [`vec`]: vec/index.html #![warn( @@ -66,7 +71,7 @@ ), feature(stdsimd, f16c_target_feature) )] -#![doc(html_root_url = "https://docs.rs/half/1.6.0")] +#![doc(html_root_url = "https://docs.rs/half/1.7.1")] #[cfg(all(feature = "alloc", not(feature = "std")))] extern crate alloc; -- cgit v1.2.3