Use maplit for static hash map literal
This commit is contained in:
parent
5ea9dbef71
commit
29a7d58b41
4 changed files with 18 additions and 21 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -344,6 +344,11 @@ dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "maplit"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matches"
|
name = "matches"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
@ -575,6 +580,7 @@ dependencies = [
|
||||||
"hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libsqlite3-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libsqlite3-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"maplit 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pulldown-cmark 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pulldown-cmark 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -989,6 +995,7 @@ dependencies = [
|
||||||
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
|
||||||
"checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527"
|
"checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527"
|
||||||
"checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699"
|
"checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699"
|
||||||
|
"checksum maplit 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ed95049d40b8a1a7691adbabca028ad481f7e6a2921ce4846e1ee168b4e4ca5"
|
||||||
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
|
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
|
||||||
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
|
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
|
||||||
"checksum mime 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "153f98dde2b135dece079e5478ee400ae1bab13afa52d66590eacfc40e912435"
|
"checksum mime 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "153f98dde2b135dece079e5478ee400ae1bab13afa52d66590eacfc40e912435"
|
||||||
|
|
|
@ -18,6 +18,7 @@ futures = "0.1"
|
||||||
futures-cpupool = "0.1"
|
futures-cpupool = "0.1"
|
||||||
hyper = "0.11"
|
hyper = "0.11"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
maplit = "1"
|
||||||
percent-encoding = "1.0.0"
|
percent-encoding = "1.0.0"
|
||||||
r2d2 = "0.7"
|
r2d2 = "0.7"
|
||||||
r2d2-diesel = "0.16"
|
r2d2-diesel = "0.16"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#[macro_use] extern crate diesel_codegen;
|
#[macro_use] extern crate diesel_codegen;
|
||||||
#[macro_use] extern crate hyper;
|
#[macro_use] extern crate hyper;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
|
#[macro_use] extern crate maplit;
|
||||||
#[macro_use] extern crate serde_derive;
|
#[macro_use] extern crate serde_derive;
|
||||||
#[macro_use] extern crate static_resource_derive;
|
#[macro_use] extern crate static_resource_derive;
|
||||||
|
|
||||||
|
|
|
@ -16,30 +16,18 @@ type BoxResource = Box<Resource + Sync + Send>;
|
||||||
type ResourceFn = Box<Fn() -> BoxResource + Sync + Send>;
|
type ResourceFn = Box<Fn() -> BoxResource + Sync + Send>;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref ASSETS_MAP: HashMap<String, ResourceFn> = {
|
static ref ASSETS_MAP: HashMap<String, ResourceFn> = hashmap!{
|
||||||
let mut map = HashMap::new();
|
format!("style-{}.css", StyleCss::checksum()) =>
|
||||||
|
Box::new(|| Box::new(StyleCss) as BoxResource) as ResourceFn,
|
||||||
|
|
||||||
map.insert(
|
format!("script-{}.js", ScriptJs::checksum()) =>
|
||||||
format!("style-{}.css", StyleCss::checksum()),
|
Box::new(|| Box::new(ScriptJs) as BoxResource) as ResourceFn,
|
||||||
Box::new(|| Box::new(StyleCss) as BoxResource) as ResourceFn
|
|
||||||
);
|
|
||||||
|
|
||||||
map.insert(
|
format!("search-{}.js", SearchJs::checksum()) =>
|
||||||
format!("script-{}.js", ScriptJs::checksum()),
|
Box::new(|| Box::new(SearchJs) as BoxResource) as ResourceFn,
|
||||||
Box::new(|| Box::new(ScriptJs) as BoxResource) as ResourceFn
|
|
||||||
);
|
|
||||||
|
|
||||||
map.insert(
|
format!("amatic-sc-v9-latin-regular.woff") =>
|
||||||
format!("search-{}.js", SearchJs::checksum()),
|
Box::new(|| Box::new(AmaticFont) as BoxResource) as ResourceFn,
|
||||||
Box::new(|| Box::new(SearchJs) as BoxResource) as ResourceFn
|
|
||||||
);
|
|
||||||
|
|
||||||
map.insert(
|
|
||||||
format!("amatic-sc-v9-latin-regular.woff"),
|
|
||||||
Box::new(|| Box::new(AmaticFont) as BoxResource) as ResourceFn
|
|
||||||
);
|
|
||||||
|
|
||||||
map
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue