Skip to content

Commit 0ce1442

Browse files
authored
Merge pull request #657 from tisonkun/relax-feature-flag
Relax feature flag for value's std_support
2 parents 67e025a + a61f95d commit 0ce1442

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- run: cargo test --verbose --features kv
4848
- run: cargo test --verbose --features kv_sval
4949
- run: cargo test --verbose --features kv_serde
50+
- run: cargo test --verbose --features kv,std
5051
- run: cargo test --verbose --features "kv kv_std kv_sval kv_serde"
5152
- run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml
5253
- run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml --release

src/kv/value.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'v> Value<'v> {
385385
}
386386
}
387387

388-
#[cfg(feature = "kv_std")]
388+
#[cfg(feature = "std")]
389389
mod std_support {
390390
use std::borrow::Cow;
391391
use std::rc::Rc;
@@ -432,20 +432,29 @@ mod std_support {
432432
}
433433
}
434434

435-
impl<'v> Value<'v> {
436-
/// Try to convert this value into a string.
437-
pub fn to_cow_str(&self) -> Option<Cow<'v, str>> {
438-
self.inner.to_str()
439-
}
440-
}
441-
442435
impl<'v> From<&'v String> for Value<'v> {
443436
fn from(v: &'v String) -> Self {
444437
Value::from(&**v)
445438
}
446439
}
447440
}
448441

442+
#[cfg(all(feature = "std", feature = "value-bag"))]
443+
impl<'v> Value<'v> {
444+
/// Try to convert this value into a string.
445+
pub fn to_cow_str(&self) -> Option<std::borrow::Cow<'v, str>> {
446+
self.inner.to_str()
447+
}
448+
}
449+
450+
#[cfg(all(feature = "std", not(feature = "value-bag")))]
451+
impl<'v> Value<'v> {
452+
/// Try to convert this value into a string.
453+
pub fn to_cow_str(&self) -> Option<std::borrow::Cow<'v, str>> {
454+
self.inner.to_borrowed_str().map(std::borrow::Cow::Borrowed)
455+
}
456+
}
457+
449458
/// A visitor for a [`Value`].
450459
///
451460
/// Also see [`Value`'s documentation on seralization]. Value visitors are a simple alternative

0 commit comments

Comments
 (0)