7
7
//! [`FluentBundle`]: ../bundle/struct.FluentBundle.html
8
8
9
9
use std:: borrow:: Borrow ;
10
- use std:: collections:: HashMap ;
11
10
use std:: fmt:: Write ;
12
11
13
12
use fluent_syntax:: ast;
14
13
use fluent_syntax:: unicode:: unescape_unicode;
15
14
16
- use crate :: bundle:: FluentBundle ;
15
+ use crate :: bundle:: { FluentArgs , FluentBundle } ;
17
16
use crate :: entry:: GetEntry ;
18
17
use crate :: resource:: FluentResource ;
19
18
use crate :: types:: DisplayableNode ;
@@ -31,20 +30,17 @@ pub struct Scope<'bundle, R: Borrow<FluentResource>> {
31
30
/// The current `FluentBundle` instance.
32
31
pub bundle : & ' bundle FluentBundle < R > ,
33
32
/// The current arguments passed by the developer.
34
- args : Option < & ' bundle HashMap < String , FluentValue < ' bundle > > > ,
33
+ args : Option < & ' bundle FluentArgs < ' bundle > > ,
35
34
/// Local args
36
- local_args : Option < HashMap < String , FluentValue < ' bundle > > > ,
35
+ local_args : Option < FluentArgs < ' bundle > > ,
37
36
/// Tracks hashes to prevent infinite recursion.
38
37
travelled : smallvec:: SmallVec < [ & ' bundle ast:: Pattern < ' bundle > ; 2 ] > ,
39
38
/// Track errors accumulated during resolving.
40
39
pub errors : Vec < ResolverError > ,
41
40
}
42
41
43
42
impl < ' bundle , R : Borrow < FluentResource > > Scope < ' bundle , R > {
44
- pub fn new (
45
- bundle : & ' bundle FluentBundle < R > ,
46
- args : Option < & ' bundle HashMap < String , FluentValue > > ,
47
- ) -> Self {
43
+ pub fn new ( bundle : & ' bundle FluentBundle < R > , args : Option < & ' bundle FluentArgs > ) -> Self {
48
44
Scope {
49
45
bundle,
50
46
args,
@@ -281,23 +277,20 @@ impl<'source> ResolveValue<'source> for ast::InlineExpression<'source> {
281
277
fn get_arguments < ' bundle , R > (
282
278
scope : & mut Scope < ' bundle , R > ,
283
279
arguments : & ' bundle Option < ast:: CallArguments < ' bundle > > ,
284
- ) -> (
285
- Vec < FluentValue < ' bundle > > ,
286
- HashMap < String , FluentValue < ' bundle > > ,
287
- )
280
+ ) -> ( Vec < FluentValue < ' bundle > > , FluentArgs < ' bundle > )
288
281
where
289
282
R : Borrow < FluentResource > ,
290
283
{
291
284
let mut resolved_positional_args = Vec :: new ( ) ;
292
- let mut resolved_named_args = HashMap :: new ( ) ;
285
+ let mut resolved_named_args = FluentArgs :: new ( ) ;
293
286
294
287
if let Some ( ast:: CallArguments { named, positional } ) = arguments {
295
288
for expression in positional {
296
289
resolved_positional_args. push ( expression. resolve ( scope) ) ;
297
290
}
298
291
299
292
for arg in named {
300
- resolved_named_args. insert ( arg. name . name . to_string ( ) , arg. value . resolve ( scope) ) ;
293
+ resolved_named_args. insert ( arg. name . name , arg. value . resolve ( scope) ) ;
301
294
}
302
295
}
303
296
0 commit comments