File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ mod render;
4444#[ doc( hidden) ] // without this we get spurious missing_docs warnings
4545mod send_sync;
4646mod shader;
47+ pub mod size;
4748mod surface;
4849mod texture;
4950mod tokens;
Original file line number Diff line number Diff line change 1+ //! Utilities for converting between [`usize`]s and fixed-size integrals in wgpu, mostly
2+ //! [`usize_from_u32`].
3+ //!
4+ //! wgpu crates only support 32-bit targets. This module both enforces this at compile time, and
5+ //! offers conveniences for converting between [`u32`] and [`usize`] that [`core`] cannot provide,
6+ //! because Rust's minimum assumed word size is 16 bits.
7+
8+ /// This is the load-bearing constant type assertion for the rest of the module. If this is true,
9+ /// then everything else should Just Work™.
10+ const _: ( ) = assert ! (
11+ size_of:: <usize >( ) >= size_of:: <u32 >( ) ,
12+ "word sizes < 32 bits are not supported in wgpu crates"
13+ ) ;
14+
15+ /// Convert a [`u32`] to a [`usize`].
16+ pub const fn usize_from_u32 ( n : u32 ) -> usize {
17+ n as usize
18+ }
You can’t perform that action at this time.
0 commit comments