From d743e25f520915f9b7c900eec36f39a25d58949a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 5 Mar 2025 22:07:24 +0400 Subject: [PATCH 1/4] fix: no-std with serde feature --- .github/workflows/ci.yml | 2 +- Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c352cf..2f3843b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: toolchain: ${{ matrix.rust }} - name: Build (no_std) - run: cargo build --no-default-features + run: cargo build --no-default-features --features "${{ matrix.features }}" - name: Build run: cargo build --features "${{ matrix.features }}" diff --git a/Cargo.toml b/Cargo.toml index a74d49a..4458783 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,12 @@ keywords = ["data-structure", "no_std"] categories = ["data-structures", "no-std"] [dependencies] -serde = { version = "1.0", optional = true, features = ["derive"] } +serde = { version = "1.0", optional = true, default-features = false, features = ["alloc", "derive"] } [features] default = ["use_std"] use_std = [] +std = ["use_std"] [dev-dependencies] serde_json = "1.0.0" From 8c1ea3e557b0e7ffb4dd9a23c6632352df26bbb4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 5 Mar 2025 22:57:14 +0400 Subject: [PATCH 2/4] use_std -> std --- Cargo.toml | 6 +++--- src/lib.rs | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4458783..ca39981 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,9 @@ categories = ["data-structures", "no-std"] serde = { version = "1.0", optional = true, default-features = false, features = ["alloc", "derive"] } [features] -default = ["use_std"] -use_std = [] -std = ["use_std"] +default = ["std"] +std = [] +use_std = ["std"] # deprecated alias [dev-dependencies] serde_json = "1.0.0" diff --git a/src/lib.rs b/src/lib.rs index 6d2b57a..fb7c837 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ //! //! **Crate features:** //! -//! * `"use_std"` +//! * `"std"` //! Enabled by default. Disable to make the library `#![no_std]`. //! //! * `"serde"` @@ -15,7 +15,7 @@ #![doc(html_root_url = "https://docs.rs/either/1/")] #![no_std] -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] extern crate std; #[cfg(feature = "serde")] @@ -31,9 +31,9 @@ use core::ops::Deref; use core::ops::DerefMut; use core::pin::Pin; -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] use std::error::Error; -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] use std::io::{self, BufRead, Read, Seek, SeekFrom, Write}; pub use crate::Either::{Left, Right}; @@ -1154,10 +1154,10 @@ where } } -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] /// `Either` implements `Read` if both `L` and `R` do. /// -/// Requires crate feature `"use_std"` +/// Requires crate feature `"std"` impl Read for Either where L: Read, @@ -1180,10 +1180,10 @@ where } } -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] /// `Either` implements `Seek` if both `L` and `R` do. /// -/// Requires crate feature `"use_std"` +/// Requires crate feature `"std"` impl Seek for Either where L: Seek, @@ -1194,8 +1194,8 @@ where } } -#[cfg(any(test, feature = "use_std"))] -/// Requires crate feature `"use_std"` +#[cfg(any(test, feature = "std"))] +/// Requires crate feature `"std"` impl BufRead for Either where L: BufRead, @@ -1218,10 +1218,10 @@ where } } -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] /// `Either` implements `Write` if both `L` and `R` do. /// -/// Requires crate feature `"use_std"` +/// Requires crate feature `"std"` impl Write for Either where L: Write, @@ -1279,17 +1279,17 @@ macro_rules! impl_specific_ref_and_mut { impl_specific_ref_and_mut!(str,); impl_specific_ref_and_mut!( ::std::path::Path, - cfg(feature = "use_std"), + cfg(feature = "std"), doc = "Requires crate feature `use_std`." ); impl_specific_ref_and_mut!( ::std::ffi::OsStr, - cfg(feature = "use_std"), + cfg(feature = "std"), doc = "Requires crate feature `use_std`." ); impl_specific_ref_and_mut!( ::std::ffi::CStr, - cfg(feature = "use_std"), + cfg(feature = "std"), doc = "Requires crate feature `use_std`." ); @@ -1345,10 +1345,10 @@ where } } -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] /// `Either` implements `Error` if *both* `L` and `R` implement it. /// -/// Requires crate feature `"use_std"` +/// Requires crate feature `"std"` impl Error for Either where L: Error, @@ -1553,7 +1553,7 @@ fn _unsized_ref_propagation() { } // This "unused" method is here to ensure that compilation doesn't fail on given types. -#[cfg(feature = "use_std")] +#[cfg(feature = "std")] fn _unsized_std_propagation() { check_t!(::std::path::Path); check_t!(::std::ffi::OsStr); From 2b71801b050d2427084927df900f1166391c89ed Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 5 Mar 2025 22:57:19 +0400 Subject: [PATCH 3/4] serde 1.0.95 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ca39981..b700ce0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ keywords = ["data-structure", "no_std"] categories = ["data-structures", "no-std"] [dependencies] -serde = { version = "1.0", optional = true, default-features = false, features = ["alloc", "derive"] } +serde = { version = "1.0.95", optional = true, default-features = false, features = ["alloc", "derive"] } [features] default = ["std"] From 80b6f2a7fd74ccf1480e9e85430c42c747999907 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 5 Mar 2025 23:26:58 +0400 Subject: [PATCH 4/4] fix last references of use_std --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fb7c837..e2265eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1280,17 +1280,17 @@ impl_specific_ref_and_mut!(str,); impl_specific_ref_and_mut!( ::std::path::Path, cfg(feature = "std"), - doc = "Requires crate feature `use_std`." + doc = "Requires crate feature `std`." ); impl_specific_ref_and_mut!( ::std::ffi::OsStr, cfg(feature = "std"), - doc = "Requires crate feature `use_std`." + doc = "Requires crate feature `std`." ); impl_specific_ref_and_mut!( ::std::ffi::CStr, cfg(feature = "std"), - doc = "Requires crate feature `use_std`." + doc = "Requires crate feature `std`." ); impl AsRef<[Target]> for Either