@@ -924,7 +924,9 @@ use_decl : "pub" ? "use" [ path "as" ident
924
924
925
925
path_glob : ident [ "::" [ path_glob
926
926
| '*' ] ] ?
927
- | '{' ident [ ',' ident ] * '}' ;
927
+ | '{' path_item [ ',' path_item ] * '}' ;
928
+
929
+ path_item : ident | "mod" ;
928
930
~~~~
929
931
930
932
A _ use declaration_ creates one or more local name bindings synonymous
@@ -943,14 +945,18 @@ Use declarations support a number of convenient shortcuts:
943
945
* Simultaneously binding a list of paths differing only in their final element,
944
946
using the glob-like brace syntax ` use a::b::{c,d,e,f}; `
945
947
* Binding all paths matching a given prefix, using the asterisk wildcard syntax ` use a::b::*; `
948
+ * Simultaneously binding a list of paths differing only in their final element
949
+ and their immediate parent module, using the ` mod ` keyword, such as ` use a::b::{mod, c, d}; `
946
950
947
951
An example of ` use ` declarations:
948
952
949
953
~~~~
950
954
use std::iter::range_step;
951
955
use std::option::{Some, None};
956
+ use std::collections::hashmap::{mod, HashMap};
952
957
953
958
# fn foo<T>(_: T){}
959
+ # fn bar(map: HashMap<String, uint>, set: hashmap::HashSet<String>){}
954
960
955
961
fn main() {
956
962
// Equivalent to 'std::iter::range_step(0u, 10u, 2u);'
@@ -959,6 +965,11 @@ fn main() {
959
965
// Equivalent to 'foo(vec![std::option::Some(1.0f64),
960
966
// std::option::None]);'
961
967
foo(vec![Some(1.0f64), None]);
968
+
969
+ // Both `hash` and `HashMap` are in scope.
970
+ let map = HashMap::new();
971
+ let set = hashmap::HashSet::new();
972
+ bar(map, set);
962
973
}
963
974
~~~~
964
975
0 commit comments