Correct create_surface_from_(offscreen)_canvas docs. (#2990)

The function's does not depend on the `canvas` argument meeting the
given requirements to avoid undefined behavior, so it should just be a
normal contract, not a safety contract.
This commit is contained in:
Jim Blandy 2022-09-02 16:29:06 -07:00 committed by GitHub
parent 6348a07d28
commit 7e84bb2eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -101,14 +101,16 @@ the same every time it is rendered, we now warn if it is missing.
- Add WGSL examples to complement existing examples written in GLSL by @norepimorphism in [#2888](https://github.com/gfx-rs/wgpu/pull/2888)
- Document `wgpu_core` resource allocation. @jimb in [#2973](https://github.com/gfx-rs/wgpu/pull/2973)
- Expanded `StagingBelt` documentation by @kpreid in [#2905](https://github.com/gfx-rs/wgpu/pull/2905)
- Fixed documentation for `Instance::create_surface_from_canvas` and
`Instance::create_surface_from_offscreen_canvas` regarding their
safety contract. These functions are not unsafe. [#2990](https://github.com/gfx-rs/wgpu/pull/2990)
### Performance
- Made `StagingBelt::write_buffer()` check more thoroughly for reusable memory; by @kpreid in [#2906](https://github.com/gfx-rs/wgpu/pull/2906)
### Documentation
- Expanded `StagingBelt` documentation by @kpreid in [#2905](https://github.com/gfx-rs/wgpu/pull/2905)
### Build Configuration
- Add the `"strict_asserts"` feature, to enable additional internal

View File

@ -1792,9 +1792,8 @@ impl Instance {
/// Creates a surface from a `web_sys::HtmlCanvasElement`.
///
/// # Safety
///
/// - canvas must be a valid <canvas> element to create a surface upon.
/// The `canvas` argument must be a valid `<canvas>` element to
/// create a surface upon.
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
pub fn create_surface_from_canvas(&self, canvas: &web_sys::HtmlCanvasElement) -> Surface {
Surface {
@ -1805,9 +1804,8 @@ impl Instance {
/// Creates a surface from a `web_sys::OffscreenCanvas`.
///
/// # Safety
///
/// - canvas must be a valid OffscreenCanvas to create a surface upon.
/// The `canvas` argument must be a valid `OffscreenCanvas` object
/// to create a surface upon.
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
pub fn create_surface_from_offscreen_canvas(
&self,