Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl std::error::Error for Error {}
pub type Response = Result<Vec<u8>, Error>;

/// Filesystem path on desktops or HTTP URL in WASM
pub fn load_file<F: Fn(Response) + 'static>(path: &str, on_loaded: F) {
pub fn load_file<F: FnOnce(Response) + 'static>(path: &str, on_loaded: F) {
#[cfg(target_arch = "wasm32")]
wasm::load_file(path, on_loaded);

Expand All @@ -50,7 +50,7 @@ pub fn load_file<F: Fn(Response) + 'static>(path: &str, on_loaded: F) {
}

#[cfg(target_os = "android")]
fn load_file_android<F: Fn(Response)>(path: &str, on_loaded: F) {
fn load_file_android<F: FnOnce(Response)>(path: &str, on_loaded: F) {
fn load_file_sync(path: &str) -> Response {
use crate::native;

Expand Down Expand Up @@ -84,7 +84,7 @@ mod wasm {

thread_local! {
#[allow(clippy::type_complexity)]
static FILES: RefCell<HashMap<u32, Box<dyn Fn(Response)>>> = RefCell::new(HashMap::new());
static FILES: RefCell<HashMap<u32, Box<dyn FnOnce(Response)>>> = RefCell::new(HashMap::new());
}

#[no_mangle]
Expand All @@ -109,7 +109,7 @@ mod wasm {
})
}

pub fn load_file<F: Fn(Response) + 'static>(path: &str, on_loaded: F) {
pub fn load_file<F: FnOnce(Response) + 'static>(path: &str, on_loaded: F) {
use native::wasm::fs;
use std::ffi::CString;

Expand All @@ -123,7 +123,7 @@ mod wasm {
}

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
fn load_file_desktop<F: Fn(Response)>(path: &str, on_loaded: F) {
fn load_file_desktop<F: FnOnce(Response)>(path: &str, on_loaded: F) {
fn load_file_sync(path: &str) -> Response {
use std::fs::File;
use std::io::Read;
Expand Down
2 changes: 1 addition & 1 deletion src/native/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
_: ObjcId,
) -> BOOL {
unsafe {
let (f, conf) = RUN_ARGS.take().unwrap();

Check warning on line 483 in src/native/ios.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, aarch64-apple-ios)

creating a mutable reference to mutable static is discouraged

Check warning on line 483 in src/native/ios.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-ios)

creating a mutable reference to mutable static is discouraged

let main_screen: ObjcId = msg_send![class!(UIScreen), mainScreen];
let screen_rect: NSRect = msg_send![main_screen, bounds];
Expand Down Expand Up @@ -782,7 +782,7 @@
let _: () = unsafe { frameworks::NSLog(nsstring) };
}

pub fn load_file<F: Fn(crate::fs::Response) + 'static>(path: &str, on_loaded: F) {
pub fn load_file<F: FnOnce(crate::fs::Response) + 'static>(path: &str, on_loaded: F) {
let path = std::path::Path::new(&path);
let path_without_extension = path.with_extension("");
let path_without_extension = path_without_extension.to_str().unwrap();
Expand Down
Loading