diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 38203e9..39892cb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -10,7 +10,7 @@ jobs: matrix: rust: - stable - - 1.63.0 + - 1.90.0 steps: - uses: r7kamura/rust-problem-matchers@v1 @@ -56,4 +56,4 @@ jobs: run: cargo test --features ${{ env.all_features }} env: - all_features: "arbitrary,bytemuck,rand,randtest,serde,schemars,proptest,rkyv,rkyv_ck,speedy" + all_features: "arbitrary,bytemuck,rand,randtest,serde,schemars,proptest,rkyv,rkyv_ck,speedy,facet" diff --git a/Cargo.lock b/Cargo.lock index d5e52a7..9bb8e07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" @@ -129,6 +129,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" +[[package]] +name = "const-fnv1a-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" + [[package]] name = "convert_case" version = "0.4.0" @@ -179,6 +185,72 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "facet" +version = "0.46.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df488bcda61dde160301ee6bce43d42397db599ffc689381a1873b5f035135f9" +dependencies = [ + "autocfg", + "facet-core", + "facet-macros", +] + +[[package]] +name = "facet-core" +version = "0.46.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33cf9d80307e9a29f93e5a65ddb65b227b5fa082d649c65d4083345f5d398d0" +dependencies = [ + "autocfg", + "const-fnv1a-hash", + "impls", +] + +[[package]] +name = "facet-macro-parse" +version = "0.46.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5ab349bd1823fbfa129e595a826ef7fb4d1b9c7215428b28de18044d009dbc1" +dependencies = [ + "facet-macro-types", + "proc-macro2", + "quote", +] + +[[package]] +name = "facet-macro-types" +version = "0.46.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79622a74665b47d1744998dd0d15b73eb0eecdfeb16630b436c5f03365b02e55" +dependencies = [ + "proc-macro2", + "quote", + "unsynn", +] + +[[package]] +name = "facet-macros" +version = "0.46.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6656fc7457975f5e1c86791b7a810c40ba53993823ae655f7c331e808c4b5ff" +dependencies = [ + "facet-macros-impl", +] + +[[package]] +name = "facet-macros-impl" +version = "0.46.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f462bad2b5a574b2c94e9ad54162704ceacf3200741b4f0fb88020936b9003ec" +dependencies = [ + "facet-macro-parse", + "facet-macro-types", + "proc-macro2", + "quote", + "unsynn", +] + [[package]] name = "fastrand" version = "2.5.0" @@ -240,6 +312,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "impls" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a46645bbd70538861a90d0f26c31537cdf1e44aae99a794fb75a664b70951bc" + [[package]] name = "itertools" version = "0.10.5" @@ -308,6 +386,12 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "mutants" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126" + [[package]] name = "num-cmp" version = "0.1.0" @@ -338,6 +422,7 @@ dependencies = [ "borsh", "bytemuck", "derive-visitor", + "facet", "num-cmp", "num-traits", "proptest", @@ -636,6 +721,12 @@ dependencies = [ "syn 3.0.3", ] +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + [[package]] name = "rustix" version = "1.1.4" @@ -884,6 +975,17 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "unsynn" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501a7adf1a4bd9951501e5c66621e972ef8874d787628b7f90e64f936ef7ec0a" +dependencies = [ + "mutants", + "proc-macro2", + "rustc-hash", +] + [[package]] name = "version_check" version = "0.9.5" diff --git a/Cargo.toml b/Cargo.toml index 566ade6..8b6b247 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,13 +12,14 @@ readme = "README.md" keywords = ["no_std", "ord", "f64", "f32", "sort"] categories = ["science", "rust-patterns", "no-std"] edition = "2021" -rust-version = "1.63" +rust-version = "1.90" [dependencies] arbitrary = { version = "1.0.0", optional = true } borsh = { version = "1.2.0", optional = true, default-features = false } bytemuck = { version = "1.12.2", optional = true, default-features = false } derive-visitor = { version = "0.4.0", optional = true } +facet = { version = "0.46.5", optional = true, default-features = false, features = ["alloc"] } num-cmp = { version = "0.1.0", optional = true } num-traits = { version = "0.2.9", default-features = false } proptest = { version = "1.0.0", optional = true } @@ -35,6 +36,7 @@ serde_test = "1.0" [features] default = ["std"] +facet = ["dep:facet"] std = ["num-traits/std"] libm = ["num-traits/libm"] serde = ["dep:serde", "rand?/serde1"] diff --git a/src/lib.rs b/src/lib.rs index 6c2decb..bba21d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,8 @@ use core::ops::{ }; use core::str::FromStr; +#[cfg(feature = "facet")] +use facet::Facet; pub use num_traits::float::FloatCore; #[cfg(any(feature = "std", feature = "libm"))] use num_traits::real::Real; @@ -88,7 +90,8 @@ pub use impl_rand::{UniformNotNan, UniformOrdered}; doc = "[`bytemuck`]: https://docs.rs/bytemuck/1/" )] #[derive(Default, Clone, Copy)] -#[repr(transparent)] +#[cfg_attr(feature = "facet", derive(Facet))] +#[cfg_attr(feature = "facet", facet(transparent))] pub struct OrderedFloat(pub T); #[cfg(feature = "derive-visitor")] @@ -1254,6 +1257,8 @@ impl Num for OrderedFloat { doc = "[`bytemuck`]: https://docs.rs/bytemuck/1/" )] #[derive(PartialOrd, PartialEq, Default, Clone, Copy)] +#[cfg_attr(feature = "facet", derive(Facet))] +#[cfg_attr(feature = "facet", facet(transparent))] #[repr(transparent)] pub struct NotNan(T);