diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dee0bfee1..d9979825e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,16 +103,17 @@ jobs: - run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic - run: cargo clippy --all-features --tests -- -Dclippy::all -Dclippy::pedantic - docs: + doc: name: Documentation runs-on: ubuntu-latest timeout-minutes: 45 + env: + RUSTDOCFLAGS: -Dwarnings steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - - run: cargo doc --features raw_value,unbounded_depth - env: - RUSTDOCFLAGS: --cfg docsrs + - uses: dtolnay/install@cargo-docs-rs + - run: cargo docs-rs fuzz: name: Fuzz diff --git a/Cargo.toml b/Cargo.toml index c79f6a79f..5851979e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_json" -version = "1.0.107" # remember to update html_root_url +version = "1.0.108" authors = ["Erick Tryzelaar ", "David Tolnay "] categories = ["encoding", "parser-implementations", "no-std"] description = "A JSON serialization file format" diff --git a/src/lib.rs b/src/lib.rs index 347bbaf0b..ce377458f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,7 +299,7 @@ //! [macro]: crate::json //! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.107")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.108")] // Ignored clippy lints #![allow( clippy::collapsible_else_if, diff --git a/src/read.rs b/src/read.rs index fc3a3ca74..7446f28b9 100644 --- a/src/read.rs +++ b/src/read.rs @@ -81,7 +81,7 @@ pub trait Read<'de>: private::Sealed { #[doc(hidden)] fn ignore_str(&mut self) -> Result<()>; - /// Assumes the previous byte was a hex escape sequnce ('\u') in a string. + /// Assumes the previous byte was a hex escape sequence ('\u') in a string. /// Parses next hexadecimal sequence. #[doc(hidden)] fn decode_hex_escape(&mut self) -> Result; diff --git a/src/value/from.rs b/src/value/from.rs index 159592ba8..ed1e3338b 100644 --- a/src/value/from.rs +++ b/src/value/from.rs @@ -28,7 +28,8 @@ from_integer! { } impl From for Value { - /// Convert 32-bit floating point number to `Value` + /// Convert 32-bit floating point number to `Value::Number`, or + /// `Value::Null` if infinite or NaN. /// /// # Examples /// @@ -44,7 +45,8 @@ impl From for Value { } impl From for Value { - /// Convert 64-bit floating point number to `Value` + /// Convert 64-bit floating point number to `Value::Number`, or + /// `Value::Null` if infinite or NaN. /// /// # Examples /// @@ -60,7 +62,7 @@ impl From for Value { } impl From for Value { - /// Convert boolean to `Value` + /// Convert boolean to `Value::Bool`. /// /// # Examples /// @@ -76,7 +78,7 @@ impl From for Value { } impl From for Value { - /// Convert `String` to `Value` + /// Convert `String` to `Value::String`. /// /// # Examples /// @@ -91,8 +93,8 @@ impl From for Value { } } -impl<'a> From<&'a str> for Value { - /// Convert string slice to `Value` +impl From<&str> for Value { + /// Convert string slice to `Value::String`. /// /// # Examples /// @@ -108,7 +110,7 @@ impl<'a> From<&'a str> for Value { } impl<'a> From> for Value { - /// Convert copy-on-write string to `Value` + /// Convert copy-on-write string to `Value::String`. /// /// # Examples /// @@ -133,7 +135,7 @@ impl<'a> From> for Value { } impl From for Value { - /// Convert `Number` to `Value` + /// Convert `Number` to `Value::Number`. /// /// # Examples /// @@ -149,7 +151,7 @@ impl From for Value { } impl From> for Value { - /// Convert map (with string keys) to `Value` + /// Convert map (with string keys) to `Value::Object`. /// /// # Examples /// @@ -166,7 +168,7 @@ impl From> for Value { } impl> From> for Value { - /// Convert a `Vec` to `Value` + /// Convert a `Vec` to `Value::Array`. /// /// # Examples /// @@ -181,8 +183,8 @@ impl> From> for Value { } } -impl<'a, T: Clone + Into> From<&'a [T]> for Value { - /// Convert a slice to `Value` +impl> From<&[T]> for Value { + /// Convert a slice to `Value::Array`. /// /// # Examples /// @@ -192,13 +194,13 @@ impl<'a, T: Clone + Into> From<&'a [T]> for Value { /// let v: &[&str] = &["lorem", "ipsum", "dolor"]; /// let x: Value = v.into(); /// ``` - fn from(f: &'a [T]) -> Self { + fn from(f: &[T]) -> Self { Value::Array(f.iter().cloned().map(Into::into).collect()) } } impl> FromIterator for Value { - /// Convert an iteratable type to a `Value` + /// Create a `Value::Array` by collecting an iterator of array elements. /// /// # Examples /// @@ -228,7 +230,7 @@ impl> FromIterator for Value { } impl, V: Into> FromIterator<(K, V)> for Value { - /// Convert an iteratable type to a `Value` + /// Create a `Value::Object` by collecting an iterator of key-value pairs. /// /// # Examples /// @@ -248,7 +250,7 @@ impl, V: Into> FromIterator<(K, V)> for Value { } impl From<()> for Value { - /// Convert `()` to `Value` + /// Convert `()` to `Value::Null`. /// /// # Examples /// diff --git a/src/value/index.rs b/src/value/index.rs index c74042b75..891ca8ef7 100644 --- a/src/value/index.rs +++ b/src/value/index.rs @@ -116,7 +116,7 @@ impl Index for String { } } -impl<'a, T> Index for &'a T +impl Index for &T where T: ?Sized + Index, { diff --git a/src/value/partial_eq.rs b/src/value/partial_eq.rs index 6b2e350b6..46c1dbc33 100644 --- a/src/value/partial_eq.rs +++ b/src/value/partial_eq.rs @@ -34,7 +34,7 @@ impl PartialEq for Value { } } -impl<'a> PartialEq<&'a str> for Value { +impl PartialEq<&str> for Value { fn eq(&self, other: &&str) -> bool { eq_str(self, *other) } @@ -46,7 +46,7 @@ impl PartialEq for str { } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { fn eq(&self, other: &Value) -> bool { eq_str(other, *self) } diff --git a/tests/lexical.rs b/tests/lexical.rs index d3dfb852b..368c84478 100644 --- a/tests/lexical.rs +++ b/tests/lexical.rs @@ -26,11 +26,6 @@ extern crate alloc; #[path = "../src/lexical/mod.rs"] mod lexical; -mod lib { - pub use std::vec::Vec; - pub use std::{cmp, iter, mem, ops}; -} - #[path = "lexical/algorithm.rs"] mod algorithm; diff --git a/tests/lexical/parse.rs b/tests/lexical/parse.rs index 80ca25e77..03ec1a9a6 100644 --- a/tests/lexical/parse.rs +++ b/tests/lexical/parse.rs @@ -1,7 +1,7 @@ // Adapted from https://github.com/Alexhuszagh/rust-lexical. use crate::lexical::num::Float; -use crate::lexical::parse::{parse_concise_float, parse_truncated_float}; +use crate::lexical::{parse_concise_float, parse_truncated_float}; use core::f64; use core::fmt::Debug; diff --git a/tests/test.rs b/tests/test.rs index e548b7dae..a38435069 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -160,17 +160,29 @@ fn test_write_f64() { #[test] fn test_encode_nonfinite_float_yields_null() { - let v = to_value(::std::f64::NAN).unwrap(); + let v = to_value(::std::f64::NAN.copysign(1.0)).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f64::NAN.copysign(-1.0)).unwrap(); assert!(v.is_null()); let v = to_value(::std::f64::INFINITY).unwrap(); assert!(v.is_null()); - let v = to_value(::std::f32::NAN).unwrap(); + let v = to_value(-::std::f64::INFINITY).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f32::NAN.copysign(1.0)).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f32::NAN.copysign(-1.0)).unwrap(); assert!(v.is_null()); let v = to_value(::std::f32::INFINITY).unwrap(); assert!(v.is_null()); + + let v = to_value(-::std::f32::INFINITY).unwrap(); + assert!(v.is_null()); } #[test]