mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
feat(span): add CompactStr::to_compact_string method (#5385)
For cases where we want to get the inner string and mutate it.
This commit is contained in:
parent
29f8497001
commit
1b20ceb70c
1 changed files with 8 additions and 0 deletions
|
|
@ -250,6 +250,12 @@ impl CompactStr {
|
|||
self.0.into_string()
|
||||
}
|
||||
|
||||
/// Convert a [`CompactStr`] into a [`CompactString`].
|
||||
#[inline]
|
||||
pub fn into_compact_string(self) -> CompactString {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// Get length of [`CompactStr`].
|
||||
///
|
||||
/// # Examples
|
||||
|
|
@ -420,6 +426,7 @@ impl schemars::JsonSchema for CompactStr {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::CompactStr;
|
||||
use compact_str::CompactString;
|
||||
|
||||
#[test]
|
||||
fn test_compactstr_eq() {
|
||||
|
|
@ -428,5 +435,6 @@ mod test {
|
|||
assert_eq!(&foo, "foo");
|
||||
assert_eq!("foo", foo);
|
||||
assert_eq!("foo", &foo);
|
||||
assert_eq!(foo.into_compact_string(), CompactString::new("foo"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue