junkdrawer 0.1.0

A crate for all kinds of utilities.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! This module contains utility functions for [`std::vec::Vec`] as well as some similar datastructures.
//! A [`Stec`] is like a Vec but entirely on the stack.
//! This means to things:
//! - No allocation required (yay no-std)
//! - No growing (oh no)

use std::mem::MaybeUninit;

/// A struct that should behave just like a [`std::vec::Vec`] but all the data is on the Stack.
///
/// Can be used in code where you know how much data you will get to avoid allocators in that part.
/// Offers all the functionality you might expect from a [`std::vec::Vec`] except the stuff explicitly for allocating memory.
pub struct Stec<T, const N: usize> {
    len: usize,
    data: [MaybeUninit<T>; N],
}