Module helpers

Module helpers 

Source
Expand description

Random assortment of helpers I didn’t know where to put.

Structs§

MetricFormatter
Point
A 2D point. Uses CoordType.
Rect
A 2D rectangle. Uses CoordType.
Size
A 2D size. Uses CoordType.

Constants§

COORD_TYPE_SAFE_MAX
To avoid overflow issues because you’re adding two CoordType::MAX values together, you can use COORD_TYPE_SAFE_MAX instead.
GIBI
GIGA
KIBI
KILO
MEBI
MEGA

Traits§

AsciiStringHelpers
Helpers for ASCII string comparisons.
ReplaceRange
Vec::splice results in really bad assembly. This doesn’t. Don’t use Vec::splice.

Functions§

file_read_uninit
Read but with MaybeUninit<u8> buffers.
minmax
std::cmp::minmax is unstable, as per usual.
opt_ptr_eq
Surprisingly, there’s no way in Rust to do a ptr::eq on Option<&T>. Uses unsafe so that the debug performance isn’t too bad.
slice_as_uninit_mut
Turns a [&mut [T]] into a [&mut [MaybeUninit<T>]].
slice_as_uninit_ref
Turns a [&[u8]] into a [&[MaybeUninit<T>]].
slice_copy_safe
[<[T]>::copy_from_slice] panics if the two slices have different lengths. This one just returns the copied amount.
str_from_raw_parts
Creates a &str from a pointer and a length. Exists, because std::str::from_raw_parts is unstable, par for the course.

Type Aliases§

CoordType
A viewport coordinate type used throughout the application.