1
1
use std:: {
2
- borrow:: Borrow ,
2
+ borrow:: { Borrow , Cow } ,
3
3
fmt, hash,
4
4
ops:: { Deref , Index } ,
5
5
} ;
@@ -9,6 +9,7 @@ use compact_str::CompactString;
9
9
use serde:: { Serialize , Serializer } ;
10
10
11
11
use crate :: Span ;
12
+ use oxc_allocator:: { Allocator , FromIn } ;
12
13
13
14
#[ cfg( feature = "serialize" ) ]
14
15
#[ wasm_bindgen:: prelude:: wasm_bindgen( typescript_custom_section) ]
@@ -58,6 +59,36 @@ impl<'a> Atom<'a> {
58
59
}
59
60
}
60
61
62
+ impl < ' a , ' b > FromIn < ' a , & ' b Atom < ' a > > for Atom < ' a > {
63
+ fn from_in ( s : & ' b Atom < ' a > , _: & ' a Allocator ) -> Self {
64
+ Self :: from ( s. 0 )
65
+ }
66
+ }
67
+
68
+ impl < ' a , ' b > FromIn < ' a , & ' b str > for Atom < ' a > {
69
+ fn from_in ( s : & ' b str , alloc : & ' a Allocator ) -> Self {
70
+ Self :: from ( oxc_allocator:: String :: from_str_in ( s, alloc) . into_bump_str ( ) )
71
+ }
72
+ }
73
+
74
+ impl < ' a > FromIn < ' a , String > for Atom < ' a > {
75
+ fn from_in ( s : String , alloc : & ' a Allocator ) -> Self {
76
+ Self :: from_in ( s. as_str ( ) , alloc)
77
+ }
78
+ }
79
+
80
+ impl < ' a > FromIn < ' a , & String > for Atom < ' a > {
81
+ fn from_in ( s : & String , alloc : & ' a Allocator ) -> Self {
82
+ Self :: from_in ( s. as_str ( ) , alloc)
83
+ }
84
+ }
85
+
86
+ impl < ' a , ' b > FromIn < ' a , Cow < ' b , str > > for Atom < ' a > {
87
+ fn from_in ( s : Cow < ' b , str > , alloc : & ' a Allocator ) -> Self {
88
+ Self :: from_in ( & * s, alloc)
89
+ }
90
+ }
91
+
61
92
impl < ' a > From < & ' a str > for Atom < ' a > {
62
93
fn from ( s : & ' a str ) -> Self {
63
94
Self ( s)
0 commit comments