pub struct GridExtent { /* private fields */ }Expand description
A validated grid shape: a non-negative width and height whose product is a cell count the runtime can actually allocate.
This is the only route from a user-supplied Int pair to a cell count.
Reaching vec![unit; (w as usize) * (h as usize)] directly would let
w = -1 become usize::MAX and the product overflow — either an allocation
the host cannot serve (an OOM abort) or a capacity-overflow panic, both
crossing extern "C". Neither is expressible here: GridExtent holds
usizes, and the multiplication it proves is the one cells() returns.
Implementations§
Source§impl GridExtent
impl GridExtent
Sourcepub const MAX_CELLS: usize
pub const MAX_CELLS: usize
The largest grid the runtime will construct: 2^28 cells, which is 2 GiB
of GcRef storage before a single cell object exists.
A cap, not a checked_mul, because a product that merely fits in a
usize is still an allocation no host can serve — Grid[Int](2^40, 2)
multiplies cleanly and then aborts the process. The number is a judgement
about what a Praxis program plausibly asks for; a program that wants more
gets a fault it can see rather than a SIGKILL it cannot.
Trait Implementations§
Source§impl Clone for GridExtent
impl Clone for GridExtent
Source§fn clone(&self) -> GridExtent
fn clone(&self) -> GridExtent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more