|
/// Filesystem path on desktops or HTTP URL in WASM |
|
pub fn load_file<F: Fn(Response) + 'static>(path: &str, on_loaded: F) { |
|
#[cfg(target_arch = "wasm32")] |
|
wasm::load_file(path, on_loaded); |
|
|
|
#[cfg(target_os = "android")] |
|
load_file_android(path, on_loaded); |
|
|
|
#[cfg(target_os = "ios")] |
|
ios::load_file(path, on_loaded); |
|
|
|
#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))] |
|
load_file_desktop(path, on_loaded); |
|
} |
fs::load_file is only expected to ever call its closure once, and thus only needs to implement FnOnce. Fn allows for the function to be called multiple times, and thus can't drop any wrapped values during its invocation. FnOnce is easier to implement and thus makes load_file easier to use.
miniquad/src/fs.rs
Lines 31 to 44 in 8a15083
fs::load_fileis only expected to ever call its closure once, and thus only needs to implementFnOnce.Fnallows for the function to be called multiple times, and thus can'tdropany wrapped values during its invocation.FnOnceis easier to implement and thus makesload_fileeasier to use.