77//! [`FluentBundle`]: ../bundle/struct.FluentBundle.html
88
99use std:: borrow:: Borrow ;
10- use std:: collections:: HashMap ;
1110use std:: fmt:: Write ;
1211
1312use fluent_syntax:: ast;
1413use fluent_syntax:: unicode:: unescape_unicode;
1514
16- use crate :: bundle:: FluentBundle ;
15+ use crate :: bundle:: { FluentArgs , FluentBundle } ;
1716use crate :: entry:: GetEntry ;
1817use crate :: resource:: FluentResource ;
1918use crate :: types:: DisplayableNode ;
@@ -31,20 +30,17 @@ pub struct Scope<'bundle, R: Borrow<FluentResource>> {
3130 /// The current `FluentBundle` instance.
3231 pub bundle : & ' bundle FluentBundle < R > ,
3332 /// The current arguments passed by the developer.
34- args : Option < & ' bundle HashMap < String , FluentValue < ' bundle > > > ,
33+ args : Option < & ' bundle FluentArgs < ' bundle > > ,
3534 /// Local args
36- local_args : Option < HashMap < String , FluentValue < ' bundle > > > ,
35+ local_args : Option < FluentArgs < ' bundle > > ,
3736 /// Tracks hashes to prevent infinite recursion.
3837 travelled : smallvec:: SmallVec < [ & ' bundle ast:: Pattern < ' bundle > ; 2 ] > ,
3938 /// Track errors accumulated during resolving.
4039 pub errors : Vec < ResolverError > ,
4140}
4241
4342impl < ' 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 {
4844 Scope {
4945 bundle,
5046 args,
@@ -281,23 +277,20 @@ impl<'source> ResolveValue<'source> for ast::InlineExpression<'source> {
281277fn get_arguments < ' bundle , R > (
282278 scope : & mut Scope < ' bundle , R > ,
283279 arguments : & ' bundle Option < ast:: CallArguments < ' bundle > > ,
284- ) -> (
285- Vec < FluentValue < ' bundle > > ,
286- HashMap < String , FluentValue < ' bundle > > ,
287- )
280+ ) -> ( Vec < FluentValue < ' bundle > > , FluentArgs < ' bundle > )
288281where
289282 R : Borrow < FluentResource > ,
290283{
291284 let mut resolved_positional_args = Vec :: new ( ) ;
292- let mut resolved_named_args = HashMap :: new ( ) ;
285+ let mut resolved_named_args = FluentArgs :: new ( ) ;
293286
294287 if let Some ( ast:: CallArguments { named, positional } ) = arguments {
295288 for expression in positional {
296289 resolved_positional_args. push ( expression. resolve ( scope) ) ;
297290 }
298291
299292 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) ) ;
301294 }
302295 }
303296
0 commit comments