Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web-sys services conversion #827

Merged
merged 11 commits into from
Jan 15, 2020
6 changes: 4 additions & 2 deletions src/services/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::fmt;
#[cfg(feature = "std_web")]
use stdweb::web::{window, Storage};
#[cfg(feature = "web_sys")]
use web_sys::Storage;
use ::{wasm_bindgen::JsValue, web_sys::Storage};

/// Represents errors of a storage.
#[derive(Debug, Fail)]
Expand Down Expand Up @@ -50,7 +50,9 @@ impl StorageService {
}
};
#[cfg(feature = "web_sys")]
let storage = storage.unwrap().unwrap();
let storage = storage
.and_then(|storage| storage.ok_or(JsValue::NULL))
.expect("failed to aquire storage");
daxpedda marked this conversation as resolved.
Show resolved Hide resolved
StorageService { storage }
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl WebSocketService {
return Err("Failed to created websocket with given URL");
}

let ws = ws.unwrap();
let ws = ws.expect("failed to build websocket");
daxpedda marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(feature = "std_web")]
ws.set_binary_type(SocketBinaryType::ArrayBuffer);
#[cfg(feature = "web_sys")]
Expand Down