From 5c6b90c721de08ba1d19a3e8e35b719bf6ed3856 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Sat, 7 Oct 2023 11:09:45 +0200 Subject: [PATCH] Remove useless `catch` --- src/readable/mod.rs | 3 +-- src/readable/sys.rs | 4 ++-- src/writable/mod.rs | 5 +---- src/writable/sys.rs | 5 ++--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/readable/mod.rs b/src/readable/mod.rs index c09ed48..e2ece84 100644 --- a/src/readable/mod.rs +++ b/src/readable/mod.rs @@ -2,8 +2,8 @@ //! [readable streams](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream). use futures_util::io::AsyncRead; use futures_util::Stream; +use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; -use wasm_bindgen::{throw_val, JsCast}; pub use byob_reader::ReadableStreamBYOBReader; pub use default_reader::ReadableStreamDefaultReader; @@ -74,7 +74,6 @@ impl ReadableStream { source, &strategy.into_raw().unchecked_into(), ) - .unwrap_or_else(|error| throw_val(error.into())) .unchecked_into(); Self { raw } } diff --git a/src/readable/sys.rs b/src/readable/sys.rs index fe6104f..4beaacb 100644 --- a/src/readable/sys.rs +++ b/src/readable/sys.rs @@ -24,11 +24,11 @@ extern "C" { #[wasm_bindgen(js_name = ReadableStream, typescript_type = "ReadableStream")] pub(crate) type ReadableStreamExt; - #[wasm_bindgen(constructor, catch, js_class = ReadableStream)] + #[wasm_bindgen(constructor, js_class = ReadableStream)] pub(crate) fn new_with_into_underlying_source( source: IntoUnderlyingSource, strategy: &QueuingStrategy, - ) -> Result; + ) -> ReadableStreamExt; #[wasm_bindgen(constructor, catch, js_class = ReadableStream)] pub(crate) fn new_with_into_underlying_byte_source( diff --git a/src/writable/mod.rs b/src/writable/mod.rs index ae8f5f9..32f1038 100644 --- a/src/writable/mod.rs +++ b/src/writable/mod.rs @@ -3,7 +3,6 @@ use futures_util::Sink; use wasm_bindgen::prelude::*; -use wasm_bindgen::throw_val; pub use default_writer::WritableStreamDefaultWriter; pub use into_async_write::IntoAsyncWrite; @@ -55,9 +54,7 @@ impl WritableStream { let sink = IntoUnderlyingSink::new(Box::new(sink)); // Use the default queuing strategy (with a HWM of 1 chunk). // We shouldn't set HWM to 0, since that would break piping to the writable stream. - let raw = sys::WritableStreamExt::new_with_into_underlying_sink(sink) - .unwrap_or_else(|error| throw_val(error.into())) - .unchecked_into(); + let raw = sys::WritableStreamExt::new_with_into_underlying_sink(sink).unchecked_into(); WritableStream { raw } } diff --git a/src/writable/sys.rs b/src/writable/sys.rs index 2f859be..911c1d1 100644 --- a/src/writable/sys.rs +++ b/src/writable/sys.rs @@ -1,7 +1,6 @@ //! Raw bindings to JavaScript objects used //! by a [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream). //! These are re-exported from [web-sys](https://docs.rs/web-sys/0.3.64/web_sys/struct.WritableStream.html). -use js_sys::Error; use wasm_bindgen::prelude::*; pub use web_sys::WritableStream; pub use web_sys::WritableStreamDefaultWriter; @@ -15,8 +14,8 @@ extern "C" { #[derive(Clone, Debug)] pub(crate) type WritableStreamExt; - #[wasm_bindgen(constructor, catch, js_class = WritableStream)] + #[wasm_bindgen(constructor, js_class = WritableStream)] pub(crate) fn new_with_into_underlying_sink( sink: IntoUnderlyingSink, - ) -> Result; + ) -> WritableStreamExt; }