Skip to content

Commit

Permalink
chore: code shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed Jan 26, 2024
1 parent 816ab03 commit 28c2d0b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ use serde_qs::from_str;
use wasm_bindgen::prelude::*;


pub fn parse_args<R: Resource + Parser + Serialize + for<'a> Deserialize<'a>>() -> R {
#[cfg(target_arch = "wasm32")]
{
let window = web_sys::window().unwrap();
let location = window.location();
let search = location.search().unwrap();

let query_string = search.trim_start_matches('?');

return from_str(query_string).unwrap();
}

#[cfg(not(target_arch = "wasm32"))]
R::parse()
}


pub struct BevyArgsPlugin<R> {
phantom: PhantomData<fn() -> R>,
}
Expand All @@ -35,24 +52,6 @@ impl<R: Default + Parser + Resource + Serialize + for<'a> Deserialize<'a>> Plugi
}
}


pub fn parse_args<R: Resource + Parser + Serialize + for<'a> Deserialize<'a>>() -> R {
#[cfg(target_arch = "wasm32")]
{
let window = web_sys::window().unwrap();
let location = window.location();
let search = location.search().unwrap();

let query_string = search.trim_start_matches('?');

return from_str(query_string).unwrap();
}

#[cfg(not(target_arch = "wasm32"))]
R::parse()
}


fn parse_args_system<R: Resource + Parser + Serialize + for<'a> Deserialize<'a>>(
mut args: ResMut<R>,
) {
Expand Down

0 comments on commit 28c2d0b

Please sign in to comment.