Skip to content

Commit

Permalink
converted to unwrap()
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy-Sheppard committed Jul 26, 2022
1 parent 8c1f485 commit e505e9c
Show file tree
Hide file tree
Showing 10 changed files with 960 additions and 641 deletions.
2 changes: 1 addition & 1 deletion examples/async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct User {
impl User {
async fn fetch(user: &str) -> Result<Self, JsValue> {
let user = fetch_github(&format!("https://api.github.com/users/{}", user)).await?;
Ok(serde_json::from_str::<Self>(&user).unwrap_throw())
Ok(serde_json::from_str::<Self>(&user).unwrap())
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/async/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub async fn fetch_github(url: &str) -> Result<String, JsValue> {
headers.set("Accept", "application/vnd.github.v3+json")?;

let future = window()
.unwrap_throw()
.unwrap()
.fetch_with_str_and_init(
url,
RequestInit::new()
Expand All @@ -131,7 +131,7 @@ pub async fn fetch_github(url: &str) -> Result<String, JsValue> {
let value = JsFuture::from(response.text()?)
.await?
.as_string()
.unwrap_throw();
.unwrap();

Ok(value)
}
8 changes: 4 additions & 4 deletions examples/todomvc/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Route {
impl Route {
// This could use more advanced URL parsing, but it isn't needed
pub fn from_url(url: &str) -> Self {
let url = Url::new(&url).unwrap_throw();
let url = Url::new(&url).unwrap();
match url.hash().as_str() {
"#/active" => Route::Active,
"#/completed" => Route::Completed,
Expand Down Expand Up @@ -72,19 +72,19 @@ impl App {
pub fn deserialize() -> Arc<Self> {
local_storage()
.get_item("todos-rust-dominator")
.unwrap_throw()
.unwrap()
.and_then(|state_json| {
serde_json::from_str(state_json.as_str()).ok()
})
.unwrap_or_else(App::new)
}

pub fn serialize(&self) {
let state_json = serde_json::to_string(self).unwrap_throw();
let state_json = serde_json::to_string(self).unwrap();

local_storage()
.set_item("todos-rust-dominator", state_json.as_str())
.unwrap_throw();
.unwrap();
}

pub fn route(&self) -> impl Signal<Item = Route> {
Expand Down
2 changes: 1 addition & 1 deletion examples/todomvc/src/todo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Todo {
.event(clone!(todo => move |event: events::KeyDown| {
match event.key().as_str() {
"Enter" => {
element.blur().unwrap_throw();
element.blur().unwrap();
},
"Escape" => {
todo.cancel_editing();
Expand Down
2 changes: 1 addition & 1 deletion examples/todomvc/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use web_sys::{window, Storage};


pub fn local_storage() -> Storage {
window().unwrap_throw().local_storage().unwrap_throw().unwrap_throw()
window().unwrap().local_storage().unwrap().unwrap()
}

#[inline]
Expand Down
Loading

0 comments on commit e505e9c

Please sign in to comment.