Skip to content

Commit 88452fa

Browse files
authored
Use alloc::vec::Vec instead of Vec for no_std support (#4378)
1 parent eb13ae3 commit 88452fa

20 files changed

+58
-38
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
* Internal functions are now removed instead of invalidly imported if they are unused.
6868
[#4366](https://github.com/rustwasm/wasm-bindgen/pull/4366)
6969

70+
* Fixed `no_std` support for all APIs in `web-sys`.
71+
[#4378](https://github.com/rustwasm/wasm-bindgen/pull/4378)
72+
7073
--------------------------------------------------------------------------------
7174

7275
## [0.2.99](https://github.com/rustwasm/wasm-bindgen/compare/0.2.98...0.2.99)

crates/web-sys/src/features/gen_AudioBuffer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,8 @@ extern "C" {
146146
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer/getChannelData)"]
147147
#[doc = ""]
148148
#[doc = "*This API requires the following crate features to be activated: `AudioBuffer`*"]
149-
pub fn get_channel_data(this: &AudioBuffer, channel: u32) -> Result<Vec<f32>, JsValue>;
149+
pub fn get_channel_data(
150+
this: &AudioBuffer,
151+
channel: u32,
152+
) -> Result<::alloc::vec::Vec<f32>, JsValue>;
150153
}

crates/web-sys/src/features/gen_DomMatrixReadOnly.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ extern "C" {
458458
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrixReadOnly/toFloat32Array)"]
459459
#[doc = ""]
460460
#[doc = "*This API requires the following crate features to be activated: `DomMatrixReadOnly`*"]
461-
pub fn to_float32_array(this: &DomMatrixReadOnly) -> Result<Vec<f32>, JsValue>;
461+
pub fn to_float32_array(this: &DomMatrixReadOnly) -> Result<::alloc::vec::Vec<f32>, JsValue>;
462462
# [wasm_bindgen (catch , method , structural , js_class = "DOMMatrixReadOnly" , js_name = toFloat64Array)]
463463
#[doc = "The `toFloat64Array()` method."]
464464
#[doc = ""]
465465
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrixReadOnly/toFloat64Array)"]
466466
#[doc = ""]
467467
#[doc = "*This API requires the following crate features to be activated: `DomMatrixReadOnly`*"]
468-
pub fn to_float64_array(this: &DomMatrixReadOnly) -> Result<Vec<f64>, JsValue>;
468+
pub fn to_float64_array(this: &DomMatrixReadOnly) -> Result<::alloc::vec::Vec<f64>, JsValue>;
469469
# [wasm_bindgen (method , structural , js_class = "DOMMatrixReadOnly" , js_name = toJSON)]
470470
#[doc = "The `toJSON()` method."]
471471
#[doc = ""]

crates/web-sys/src/features/gen_FetchReadableStreamReadDataArray.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" {
1414
#[doc = ""]
1515
#[doc = "*This API requires the following crate features to be activated: `FetchReadableStreamReadDataArray`*"]
1616
#[wasm_bindgen(method, getter = "value")]
17-
pub fn get_value(this: &FetchReadableStreamReadDataArray) -> Option<Vec<u8>>;
17+
pub fn get_value(this: &FetchReadableStreamReadDataArray) -> Option<::alloc::vec::Vec<u8>>;
1818
#[doc = "Change the `value` field of this object."]
1919
#[doc = ""]
2020
#[doc = "*This API requires the following crate features to be activated: `FetchReadableStreamReadDataArray`*"]

crates/web-sys/src/features/gen_GamepadPose.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,40 +32,44 @@ extern "C" {
3232
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadPose/position)"]
3333
#[doc = ""]
3434
#[doc = "*This API requires the following crate features to be activated: `GamepadPose`*"]
35-
pub fn position(this: &GamepadPose) -> Result<Option<Vec<f32>>, JsValue>;
35+
pub fn position(this: &GamepadPose) -> Result<Option<::alloc::vec::Vec<f32>>, JsValue>;
3636
# [wasm_bindgen (structural , catch , method , getter , js_class = "GamepadPose" , js_name = linearVelocity)]
3737
#[doc = "Getter for the `linearVelocity` field of this object."]
3838
#[doc = ""]
3939
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadPose/linearVelocity)"]
4040
#[doc = ""]
4141
#[doc = "*This API requires the following crate features to be activated: `GamepadPose`*"]
42-
pub fn linear_velocity(this: &GamepadPose) -> Result<Option<Vec<f32>>, JsValue>;
42+
pub fn linear_velocity(this: &GamepadPose) -> Result<Option<::alloc::vec::Vec<f32>>, JsValue>;
4343
# [wasm_bindgen (structural , catch , method , getter , js_class = "GamepadPose" , js_name = linearAcceleration)]
4444
#[doc = "Getter for the `linearAcceleration` field of this object."]
4545
#[doc = ""]
4646
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadPose/linearAcceleration)"]
4747
#[doc = ""]
4848
#[doc = "*This API requires the following crate features to be activated: `GamepadPose`*"]
49-
pub fn linear_acceleration(this: &GamepadPose) -> Result<Option<Vec<f32>>, JsValue>;
49+
pub fn linear_acceleration(
50+
this: &GamepadPose,
51+
) -> Result<Option<::alloc::vec::Vec<f32>>, JsValue>;
5052
# [wasm_bindgen (structural , catch , method , getter , js_class = "GamepadPose" , js_name = orientation)]
5153
#[doc = "Getter for the `orientation` field of this object."]
5254
#[doc = ""]
5355
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadPose/orientation)"]
5456
#[doc = ""]
5557
#[doc = "*This API requires the following crate features to be activated: `GamepadPose`*"]
56-
pub fn orientation(this: &GamepadPose) -> Result<Option<Vec<f32>>, JsValue>;
58+
pub fn orientation(this: &GamepadPose) -> Result<Option<::alloc::vec::Vec<f32>>, JsValue>;
5759
# [wasm_bindgen (structural , catch , method , getter , js_class = "GamepadPose" , js_name = angularVelocity)]
5860
#[doc = "Getter for the `angularVelocity` field of this object."]
5961
#[doc = ""]
6062
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadPose/angularVelocity)"]
6163
#[doc = ""]
6264
#[doc = "*This API requires the following crate features to be activated: `GamepadPose`*"]
63-
pub fn angular_velocity(this: &GamepadPose) -> Result<Option<Vec<f32>>, JsValue>;
65+
pub fn angular_velocity(this: &GamepadPose) -> Result<Option<::alloc::vec::Vec<f32>>, JsValue>;
6466
# [wasm_bindgen (structural , catch , method , getter , js_class = "GamepadPose" , js_name = angularAcceleration)]
6567
#[doc = "Getter for the `angularAcceleration` field of this object."]
6668
#[doc = ""]
6769
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadPose/angularAcceleration)"]
6870
#[doc = ""]
6971
#[doc = "*This API requires the following crate features to be activated: `GamepadPose`*"]
70-
pub fn angular_acceleration(this: &GamepadPose) -> Result<Option<Vec<f32>>, JsValue>;
72+
pub fn angular_acceleration(
73+
this: &GamepadPose,
74+
) -> Result<Option<::alloc::vec::Vec<f32>>, JsValue>;
7175
}

crates/web-sys/src/features/gen_GamepadTouch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern "C" {
4848
#[doc = ""]
4949
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
5050
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
51-
pub fn position(this: &GamepadTouch) -> Vec<f32>;
51+
pub fn position(this: &GamepadTouch) -> ::alloc::vec::Vec<f32>;
5252
#[cfg(web_sys_unstable_apis)]
5353
# [wasm_bindgen (structural , method , getter , js_class = "GamepadTouch" , js_name = surfaceDimensions)]
5454
#[doc = "Getter for the `surfaceDimensions` field of this object."]
@@ -59,5 +59,5 @@ extern "C" {
5959
#[doc = ""]
6060
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
6161
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
62-
pub fn surface_dimensions(this: &GamepadTouch) -> Option<Vec<u32>>;
62+
pub fn surface_dimensions(this: &GamepadTouch) -> Option<::alloc::vec::Vec<u32>>;
6363
}

crates/web-sys/src/features/gen_ImageData.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" {
3232
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/data)"]
3333
#[doc = ""]
3434
#[doc = "*This API requires the following crate features to be activated: `ImageData`*"]
35-
pub fn data(this: &ImageData) -> ::wasm_bindgen::Clamped<Vec<u8>>;
35+
pub fn data(this: &ImageData) -> ::wasm_bindgen::Clamped<::alloc::vec::Vec<u8>>;
3636
#[wasm_bindgen(catch, constructor, js_class = "ImageData")]
3737
#[doc = "The `new ImageData(..)` constructor, creating a new instance of `ImageData`."]
3838
#[doc = ""]

crates/web-sys/src/features/gen_MidiMessageEvent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern "C" {
1818
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MIDIMessageEvent/data)"]
1919
#[doc = ""]
2020
#[doc = "*This API requires the following crate features to be activated: `MidiMessageEvent`*"]
21-
pub fn data(this: &MidiMessageEvent) -> Result<Vec<u8>, JsValue>;
21+
pub fn data(this: &MidiMessageEvent) -> Result<::alloc::vec::Vec<u8>, JsValue>;
2222
#[wasm_bindgen(catch, constructor, js_class = "MIDIMessageEvent")]
2323
#[doc = "The `new MidiMessageEvent(..)` constructor, creating a new instance of `MidiMessageEvent`."]
2424
#[doc = ""]

crates/web-sys/src/features/gen_MidiMessageEventInit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extern "C" {
4444
#[doc = ""]
4545
#[doc = "*This API requires the following crate features to be activated: `MidiMessageEventInit`*"]
4646
#[wasm_bindgen(method, getter = "data")]
47-
pub fn get_data(this: &MidiMessageEventInit) -> Option<Vec<u8>>;
47+
pub fn get_data(this: &MidiMessageEventInit) -> Option<::alloc::vec::Vec<u8>>;
4848
#[doc = "Change the `data` field of this object."]
4949
#[doc = ""]
5050
#[doc = "*This API requires the following crate features to be activated: `MidiMessageEventInit`*"]

crates/web-sys/src/features/gen_TextEncoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ extern "C" {
3232
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encode)"]
3333
#[doc = ""]
3434
#[doc = "*This API requires the following crate features to be activated: `TextEncoder`*"]
35-
pub fn encode(this: &TextEncoder) -> Vec<u8>;
35+
pub fn encode(this: &TextEncoder) -> ::alloc::vec::Vec<u8>;
3636
# [wasm_bindgen (method , structural , js_class = "TextEncoder" , js_name = encode)]
3737
#[doc = "The `encode()` method."]
3838
#[doc = ""]
3939
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encode)"]
4040
#[doc = ""]
4141
#[doc = "*This API requires the following crate features to be activated: `TextEncoder`*"]
42-
pub fn encode_with_input(this: &TextEncoder, input: &str) -> Vec<u8>;
42+
pub fn encode_with_input(this: &TextEncoder, input: &str) -> ::alloc::vec::Vec<u8>;
4343
}

0 commit comments

Comments
 (0)