-
-
Notifications
You must be signed in to change notification settings - Fork 198
Open
Description
Lines 31 to 44 in 8a15083
/// 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.
Metadata
Metadata
Assignees
Labels
No labels