diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1eab4b88..892a630be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,7 @@ jobs: - run: cargo test --verbose --features kv - run: cargo test --verbose --features kv_sval - run: cargo test --verbose --features kv_serde + - run: cargo test --verbose --features kv,std - run: cargo test --verbose --features "kv kv_std kv_sval kv_serde" - run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml - run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml --release diff --git a/src/kv/value.rs b/src/kv/value.rs index 2b9ca2510..6616ee961 100644 --- a/src/kv/value.rs +++ b/src/kv/value.rs @@ -385,7 +385,7 @@ impl<'v> Value<'v> { } } -#[cfg(feature = "kv_std")] +#[cfg(feature = "std")] mod std_support { use std::borrow::Cow; use std::rc::Rc; @@ -432,13 +432,6 @@ mod std_support { } } - impl<'v> Value<'v> { - /// Try to convert this value into a string. - pub fn to_cow_str(&self) -> Option> { - self.inner.to_str() - } - } - impl<'v> From<&'v String> for Value<'v> { fn from(v: &'v String) -> Self { Value::from(&**v) @@ -446,6 +439,22 @@ mod std_support { } } +#[cfg(all(feature = "std", feature = "value-bag"))] +impl<'v> Value<'v> { + /// Try to convert this value into a string. + pub fn to_cow_str(&self) -> Option> { + self.inner.to_str() + } +} + +#[cfg(all(feature = "std", not(feature = "value-bag")))] +impl<'v> Value<'v> { + /// Try to convert this value into a string. + pub fn to_cow_str(&self) -> Option> { + self.inner.to_borrowed_str().map(std::borrow::Cow::Borrowed) + } +} + /// A visitor for a [`Value`]. /// /// Also see [`Value`'s documentation on seralization]. Value visitors are a simple alternative