Skip to content

Commit 142c528

Browse files
committed
feat: add conversion between String and &'a str.
1 parent cee23c7 commit 142c528

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/oxc_allocator/src/convert.rs

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ impl<'a> FromIn<'a, String> for crate::String<'a> {
3838
}
3939
}
4040

41+
impl<'a> FromIn<'a, String> for &'a str {
42+
#[inline(always)]
43+
fn from_in(value: String, alloc: &'a Allocator) -> Self {
44+
crate::String::from_str_in(value.as_str(), alloc).into_bump_str()
45+
}
46+
}
47+
4148
impl<'a, T> FromIn<'a, T> for Box<'a, T> {
4249
#[inline(always)]
4350
fn from_in(value: T, alloc: &'a Allocator) -> Self {

0 commit comments

Comments
 (0)