From ac80079b5ae1b28dffd614b21d4a408b20d60014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 9 Jun 2024 10:57:50 +0200 Subject: [PATCH 1/6] Delegate documentation of feature requirements to docsrs doc_auto_cfg feature --- Cargo.toml | 1 + src/array_string.rs | 6 +----- src/arrayvec.rs | 8 +------- src/errors.rs | 1 - src/lib.rs | 1 + 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 256bff8..44c1adf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ debug = true [package.metadata.docs.rs] features = ["borsh", "serde", "zeroize"] +rustdoc-flags = ["--cfg", "docsrs"] [package.metadata.release] no-dev-version = true diff --git a/src/array_string.rs b/src/array_string.rs index 1144360..5218a54 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -580,7 +580,6 @@ impl FromStr for ArrayString } #[cfg(feature="serde")] -/// Requires crate feature `"serde"` impl Serialize for ArrayString { fn serialize(&self, serializer: S) -> Result @@ -591,7 +590,6 @@ impl Serialize for ArrayString } #[cfg(feature="serde")] -/// Requires crate feature `"serde"` impl<'de, const CAP: usize> Deserialize<'de> for ArrayString { fn deserialize(deserializer: D) -> Result @@ -629,7 +627,6 @@ impl<'de, const CAP: usize> Deserialize<'de> for ArrayString } #[cfg(feature = "borsh")] -/// Requires crate feature `"borsh"` impl borsh::BorshSerialize for ArrayString { fn serialize(&self, writer: &mut W) -> borsh::io::Result<()> { ::serialize(&*self, writer) @@ -637,7 +634,6 @@ impl borsh::BorshSerialize for ArrayString { } #[cfg(feature = "borsh")] -/// Requires crate feature `"borsh"` impl borsh::BorshDeserialize for ArrayString { fn deserialize_reader(reader: &mut R) -> borsh::io::Result { let len = ::deserialize_reader(reader)? as usize; @@ -683,7 +679,7 @@ impl<'a, const CAP: usize> TryFrom> for ArrayString } #[cfg(feature = "zeroize")] -/// "Best efforts" zeroing of the `ArrayString`'s buffer when the `zeroize` feature is enabled. +/// "Best efforts" zeroing of the `ArrayString`'s buffer. /// /// The length is set to 0, and the buffer is dropped and zeroized. /// Cannot ensure that previous moves of the `ArrayString` did not leave values on the stack. diff --git a/src/arrayvec.rs b/src/arrayvec.rs index e87b3ef..f52d50c 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -850,7 +850,7 @@ impl IntoIterator for ArrayVec { #[cfg(feature = "zeroize")] -/// "Best efforts" zeroing of the `ArrayVec`'s buffer when the `zeroize` feature is enabled. +/// "Best efforts" zeroing of the `ArrayVec`'s buffer. /// /// The length is set to 0, and the buffer is dropped and zeroized. /// Cannot ensure that previous moves of the `ArrayVec` did not leave values on the stack. @@ -1254,8 +1254,6 @@ impl Ord for ArrayVec where T: Ord { #[cfg(feature="std")] /// `Write` appends written data to the end of the vector. -/// -/// Requires `features="std"`. impl io::Write for ArrayVec { fn write(&mut self, data: &[u8]) -> io::Result { let len = cmp::min(self.remaining_capacity(), data.len()); @@ -1267,7 +1265,6 @@ impl io::Write for ArrayVec { } #[cfg(feature="serde")] -/// Requires crate feature `"serde"` impl Serialize for ArrayVec { fn serialize(&self, serializer: S) -> Result where S: Serializer @@ -1277,7 +1274,6 @@ impl Serialize for ArrayVec { } #[cfg(feature="serde")] -/// Requires crate feature `"serde"` impl<'de, T: Deserialize<'de>, const CAP: usize> Deserialize<'de> for ArrayVec { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de> @@ -1314,7 +1310,6 @@ impl<'de, T: Deserialize<'de>, const CAP: usize> Deserialize<'de> for ArrayVec borsh::BorshSerialize for ArrayVec where T: borsh::BorshSerialize, @@ -1325,7 +1320,6 @@ where } #[cfg(feature = "borsh")] -/// Requires crate feature `"borsh"` impl borsh::BorshDeserialize for ArrayVec where T: borsh::BorshDeserialize, diff --git a/src/errors.rs b/src/errors.rs index 7ca3ebc..8e18ae8 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -32,7 +32,6 @@ impl CapacityError { const CAPERROR: &'static str = "insufficient capacity"; #[cfg(feature="std")] -/// Requires `features="std"`. impl Error for CapacityError {} impl fmt::Display for CapacityError { diff --git a/src/lib.rs b/src/lib.rs index f9a2fe6..3212e66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,7 @@ //! #![doc(html_root_url="https://docs.rs/arrayvec/0.7/")] #![cfg_attr(not(feature="std"), no_std)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #[cfg(feature="serde")] extern crate serde; From 3525969ab3e560944231786be22dfcd1366545d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 9 Jun 2024 11:02:23 +0200 Subject: [PATCH 2/6] Add comment explaining what the rustdoc-flags line does in cargo.toml, and include a link to the stackoverflow page from which the idea is taken --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 44c1adf..0c48415 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,9 @@ debug = true [package.metadata.docs.rs] features = ["borsh", "serde", "zeroize"] +# Enables the `docsrs` cofig attribute when running on docs.rs, +# which always uses the latest nightly compiler. +# Idea taken from . rustdoc-flags = ["--cfg", "docsrs"] [package.metadata.release] From fad27d7694736ebb2c4fde0e2e84302354ee3556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 9 Jun 2024 11:02:43 +0200 Subject: [PATCH 3/6] Spelling --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0c48415..e0d9a20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ debug = true [package.metadata.docs.rs] features = ["borsh", "serde", "zeroize"] -# Enables the `docsrs` cofig attribute when running on docs.rs, +# Enables the `docsrs` config attribute when running on docs.rs, # which always uses the latest nightly compiler. # Idea taken from . rustdoc-flags = ["--cfg", "docsrs"] From cfa2224bf35633745ce7db3fa29cfa21d11b4966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 9 Jun 2024 11:04:46 +0200 Subject: [PATCH 4/6] Enable all features on docsrs for documentation --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e0d9a20..957bf52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ debug = true debug = true [package.metadata.docs.rs] -features = ["borsh", "serde", "zeroize"] +all-features = true # Enables the `docsrs` config attribute when running on docs.rs, # which always uses the latest nightly compiler. # Idea taken from . From e0a01a215a87cb5ac04c7001251ec48ca6b6a445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 9 Jun 2024 11:09:14 +0200 Subject: [PATCH 5/6] Add comment to cfg_attr(docsrs, feature(doc_auto_cfg)) --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3212e66..d5a6685 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,8 @@ //! #![doc(html_root_url="https://docs.rs/arrayvec/0.7/")] #![cfg_attr(not(feature="std"), no_std)] +// This enables the nightly feature `doc_auto_cfg` when running on docs.rs, +// which always uses the nightly compiler. #![cfg_attr(docsrs, feature(doc_auto_cfg))] #[cfg(feature="serde")] From ded0132ae77dbe9ccaca627d84d23801764c57e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Wed, 31 Jul 2024 17:40:56 +0200 Subject: [PATCH 6/6] remove unnecessary config --- Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 957bf52..f0a4691 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,10 +55,6 @@ debug = true [package.metadata.docs.rs] all-features = true -# Enables the `docsrs` config attribute when running on docs.rs, -# which always uses the latest nightly compiler. -# Idea taken from . -rustdoc-flags = ["--cfg", "docsrs"] [package.metadata.release] no-dev-version = true