Skip to content

Commit

Permalink
Merge pull request #662 from rust-lang/fix/cargo-features
Browse files Browse the repository at this point in the history
Revert loosening of kv cargo features
  • Loading branch information
KodrAus authored Jan 13, 2025
2 parents 2282191 + 36e7e3f commit 4099bcb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ release_max_level_info = []
release_max_level_debug = []
release_max_level_trace = []

std = ["value-bag?/std"]
std = []

kv = []
kv_sval = ["kv", "value-bag/sval", "sval", "sval_ref"]
Expand Down
25 changes: 8 additions & 17 deletions src/kv/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<'v> Value<'v> {
}
}

#[cfg(feature = "std")]
#[cfg(feature = "kv_std")]
mod std_support {
use std::borrow::Cow;
use std::rc::Rc;
Expand Down Expand Up @@ -432,29 +432,20 @@ mod std_support {
}
}

impl<'v> Value<'v> {
/// Try convert this value into a string.
pub fn to_cow_str(&self) -> Option<Cow<'v, str>> {
self.inner.to_str()
}
}

impl<'v> From<&'v String> for Value<'v> {
fn from(v: &'v String) -> Self {
Value::from(&**v)
}
}
}

#[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<std::borrow::Cow<'v, str>> {
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<std::borrow::Cow<'v, str>> {
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
Expand Down

0 comments on commit 4099bcb

Please sign in to comment.