rational_extensions

Extends num_rational::Ratio<T>.
git clone https://git.philomathiclife.com/repos/rational_extensions
Log | Files | Refs | README

commit 723a956cf8af18f1ebbedce384edbf79f16e60c1
parent 965537cea62d23173efdd443eeb3f96a1533436f
Author: Zack Newman <zack@philomathiclife.com>
Date:   Wed, 13 Sep 2023 11:46:57 -0600

update deps

Diffstat:
MCargo.toml | 18++++++++++++++----
Abuild.rs | 12++++++++++++
Msrc/lib.rs | 16+++++++---------
Rsrc/serde.rs -> src/rational.rs | 0
4 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" name = "rational_extensions" readme = "README.md" repository = "https://git.philomathiclife.com/repos/rational_extensions/" -version = "0.4.0" +version = "0.4.1" [lib] name = "rational_extensions" @@ -18,11 +18,21 @@ path = "src/lib.rs" [dependencies] num-integer = { version = "0.1.45", default-features = false } num-rational = { version = "0.4.1", default-features = false } -num-traits = { version = "0.2.15", default-features = false } -serde = { version = "1.0.160", default-features = false, optional = true } +num-traits = { version = "0.2.16", default-features = false } +serde = { version = "1.0.188", default-features = false, optional = true } + +[build-dependencies] +rustc_version = "0.4.0" [dev-dependencies] -serde_json = { version = "1.0.95", default-features = false, features = ["alloc"] } +serde_json = { version = "1.0.106", default-features = false, features = ["alloc"] } + +[features] +rational = ["dep:serde"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] [badges] maintenance = { status = "passively-maintained" } diff --git a/build.rs b/build.rs @@ -0,0 +1,12 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + let channel = match version_meta().unwrap().channel { + Channel::Stable => "CHANNEL_STABLE", + Channel::Beta => "CHANNEL_BETA", + Channel::Nightly => "CHANNEL_NIGHTLY", + Channel::Dev => "CHANNEL_DEV", + }; + println!("cargo:rustc-cfg={}", channel) +} diff --git a/src/lib.rs b/src/lib.rs @@ -2,8 +2,8 @@ //! from a string specifically by allowing decimal notation with the //! ability to constrain the minimum and maximum number of fractional //! digits allowed. +#![cfg_attr(all(doc, CHANNEL_NIGHTLY), feature(doc_auto_cfg))] #![no_std] -#![feature(doc_cfg)] #![deny( unsafe_code, unused, @@ -115,7 +115,7 @@ impl<T> From<T> for FromDecStrErr<T> { } } /// Converts a string in decimal notation into a `Ratio<T>`. - +/// /// # Errors /// /// Will return `FromDecStrErr` iff `val` is not a valid rational @@ -211,7 +211,7 @@ impl<T> From<T> for FromStrErr<T> { } } /// Converts a string in rational or decimal notation into a `Ratio<T>`. - +/// /// # Errors /// /// Will return `FromStrErr` iff `val` is not a rational number in @@ -290,7 +290,6 @@ where clippy::as_conversions, clippy::cast_lossless, clippy::indexing_slicing, - clippy::integer_arithmetic, clippy::string_slice )] #[inline] @@ -330,11 +329,10 @@ where // the passed value plus optionally the single byte encodings of ".", "-", and "0". unsafe { String::from_utf8_unchecked(v) } } -#[cfg(feature = "serde")] -#[doc(cfg(feature = "serde"))] -/// Enables deserialization of strings in decimal or fractional format -/// into [`serde::Rational<T>`]. -pub mod serde; +#[cfg(feature = "rational")] +// Enables deserialization of strings in decimal or fractional format +// into [`rational::Rational<T>`]. +pub mod rational; #[cfg(test)] mod tests { diff --git a/src/serde.rs b/src/rational.rs