1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

refactor: Simplify op_fetch_asset signature (#7655)

This commit is contained in:
Ryan Dahl 2020-09-24 09:29:18 -04:00 committed by GitHub
parent 6a2ce3d91f
commit 82db91372f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,8 @@
pub use deno_core::v8_set_flags; pub use deno_core::v8_set_flags;
use deno_core::BufVec; use deno_core::BufVec;
use deno_core::Op; use deno_core::Op;
use deno_core::OpState;
use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
@ -82,13 +84,13 @@ fn get_asset(name: &str) -> Option<&'static str> {
/// Warning: Returns a non-JSON op dispatcher. Must be manually attached to /// Warning: Returns a non-JSON op dispatcher. Must be manually attached to
/// JsRuntime. /// JsRuntime.
pub fn op_fetch_asset<H: std::hash::BuildHasher, S>( pub fn op_fetch_asset(
custom_assets: HashMap<String, PathBuf, H>, custom_assets: HashMap<String, PathBuf>,
) -> impl Fn(Rc<S>, BufVec) -> Op { ) -> impl Fn(Rc<RefCell<OpState>>, BufVec) -> Op {
for (_, path) in custom_assets.iter() { for (_, path) in custom_assets.iter() {
println!("cargo:rerun-if-changed={}", path.display()); println!("cargo:rerun-if-changed={}", path.display());
} }
move |_state: Rc<S>, bufs: BufVec| -> Op { move |_state: Rc<RefCell<OpState>>, bufs: BufVec| -> Op {
assert_eq!(bufs.len(), 1, "Invalid number of arguments"); assert_eq!(bufs.len(), 1, "Invalid number of arguments");
let name = std::str::from_utf8(&bufs[0]).unwrap(); let name = std::str::from_utf8(&bufs[0]).unwrap();