@@ -16,11 +16,11 @@ pub fn compile_sync(
16
16
mut options : Options ,
17
17
) -> Result < CompileResult > {
18
18
let exe = exe_path ( & options) ;
19
- let mut importers =
19
+ let importers =
20
20
ImporterRegistry :: new ( options. importers . take ( ) , options. load_paths . take ( ) ) ;
21
21
let logger = LoggerRegistry :: new ( options. logger . take ( ) ) ;
22
22
23
- let request = CompileRequest :: with_path ( path, & mut importers, & options) ;
23
+ let request = CompileRequest :: with_path ( path, & importers, & options) ;
24
24
let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
25
25
let response = rt. block_on ( async {
26
26
let embedded = Embedded :: new ( exe) ;
@@ -62,11 +62,11 @@ pub async fn compile(
62
62
mut options : Options ,
63
63
) -> Result < CompileResult > {
64
64
let exe = exe_path ( & options) ;
65
- let mut importers =
65
+ let importers =
66
66
ImporterRegistry :: new ( options. importers . take ( ) , options. load_paths . take ( ) ) ;
67
67
let logger = LoggerRegistry :: new ( options. logger . take ( ) ) ;
68
68
69
- let request = CompileRequest :: with_path ( path, & mut importers, & options) ;
69
+ let request = CompileRequest :: with_path ( path, & importers, & options) ;
70
70
let embedded = Embedded :: new ( exe) ;
71
71
let response = embedded. compile ( request, & importers, & logger) . await ?;
72
72
@@ -98,9 +98,8 @@ pub async fn compile_string(
98
98
fn exe_path ( options : & Options ) -> String {
99
99
options
100
100
. exe_path
101
- . as_ref ( )
102
- . unwrap_or ( & compiler_path:: compiler_path ( ) . unwrap ( ) )
103
- . to_string ( )
101
+ . clone ( )
102
+ . unwrap_or_else ( || compiler_path:: compiler_path ( ) . unwrap ( ) )
104
103
}
105
104
106
105
fn handle_response ( response : CompileResponse ) -> Result < CompileResult > {
@@ -116,33 +115,3 @@ fn handle_response(response: CompileResponse) -> Result<CompileResult> {
116
115
}
117
116
}
118
117
}
119
-
120
- #[ cfg( test) ]
121
- mod tests {
122
- use crate :: api:: WithoutImporter ;
123
-
124
- use super :: * ;
125
-
126
- #[ tokio:: test]
127
- async fn test_compile_string ( ) {
128
- let res = compile_string (
129
- ".foo {a: b}" . to_string ( ) ,
130
- Options :: default ( ) ,
131
- StringOptions :: WithoutImporter ( WithoutImporter :: default ( ) ) ,
132
- )
133
- . await
134
- . unwrap ( ) ;
135
- assert_eq ! ( res. css, ".foo {\n a: b;\n }" ) ;
136
- }
137
-
138
- #[ test]
139
- fn test_compile_string_sync ( ) {
140
- let res = compile_string_sync (
141
- ".foo {a: b}" . to_string ( ) ,
142
- Options :: default ( ) ,
143
- StringOptions :: WithoutImporter ( WithoutImporter :: default ( ) ) ,
144
- )
145
- . unwrap ( ) ;
146
- assert_eq ! ( res. css, ".foo {\n a: b;\n }" ) ;
147
- }
148
- }
0 commit comments