Skip to content
This repository was archived by the owner on Jul 19, 2020. It is now read-only.
Merged
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
25 changes: 14 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
use std::env;

pub fn main() {
if cfg!(all(feature = "web_sys", feature = "std_web")) {
panic!("Yew_router does not allow the `web_sys` and `std_web` cargo features to be used simultaneously");
} else if cfg!(not(any(feature = "web_sys", feature = "std_web"))) {
panic!("Yew_router requires selecting either the `web_sys` or `std_web` cargo feature");
let using_web_sys = cfg!(feature = "web_sys");
let using_std_web = cfg!(feature = "std_web");
if using_web_sys && using_std_web {
panic!("Yew does not allow the `web_sys` and `std_web` cargo features to be used simultaneously");
} else if !using_web_sys && !using_std_web {
panic!("Yew requires selecting either the `web_sys` or `std_web` cargo feature");
}

let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
let using_wasi = target_os == "wasi";

let cargo_web = env::var("COMPILING_UNDER_CARGO_WEB").unwrap_or_default();
let using_cargo_web = cargo_web == "1";
if using_cargo_web && cfg!(feature = "web_sys") {
let using_cargo_web = env::var("COMPILING_UNDER_CARGO_WEB").is_ok();
if using_cargo_web && using_web_sys {
panic!("cargo-web is not compatible with web-sys");
}

let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
let using_wasm_bindgen = target_arch == "wasm32" && !using_cargo_web && !using_wasi;
if using_wasm_bindgen {
println!("cargo:rustc-cfg=feature=\"wasm_bindgen_test\"");
} else if cfg!(all(feature = "web_sys", not(feature = "doc_test"))) {

let using_clippy = env::var("CLIPPY_ARGS").is_ok();
let running_doc_tests = cfg!(feature = "doc_test");

if !using_wasm_bindgen && using_web_sys && !running_doc_tests && !using_clippy {
let target = env::var("TARGET").unwrap_or_default();
panic!(
"Selected target `{}` is not compatible with web-sys",
target
);
}
}
}
4 changes: 2 additions & 2 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ where
log::trace!("History state is empty");
None
})
.and_then(|state_string| -> Option<Option<STATE>>{
.and_then(|state_string| -> Option<STATE> {
serde_json::from_str(&state_string)
.ok()
.or_else(|| {
log::error!("Could not deserialize state string");
None
})
.and_then(std::convert::identity) // flatten
})
.and_then(std::convert::identity) // flatten
.unwrap_or_default();
Route {
route: route_string,
Expand Down