Thanks to visit codestin.com
Credit goes to lib.rs

#status-line #life #macro #trinkets

gstuff

Small macro and trinkets that make my life easier

84 releases

0.8.29 Apr 2, 2026
0.8.28 Mar 11, 2026
0.8.27 Feb 23, 2026
0.8.25 Dec 27, 2025
0.1.2 Nov 10, 2016

#627 in Rust patterns

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

3,257 downloads per month
Used in 3 crates

MIT license

225KB
4K SLoC

gstuff - Small macro and trinkets that make my life easier.

crate docs


lib.rs:

Iterates over 0..len or a slice in pseudo-random order, with zero allocation. Uses a Feistel-like bijective permutation combined with cycle-walking to visit every index exactly once.

ShuffledIter Methods

  • fn with_seed (len: usize, seed: u64) -> ShuffledIter Creates new iterator over 0..len using given seed.

Functions

  • fn shuffled<T> (seed: u64, v: &[T]) -> impl Iterator<Item = (usize, &T)> Iterates over slice in random order, yielding (index, &T).

TPool Methods

  • fn post (&self, task: Box<dyn Task>) -> Re<()> Runs given task from one of sponsored threads.
  • fn post_at (&self, next_ms: u64, task: Box<dyn Task>) -> Re<()> Schedules task to run at next_ms epoch from one of sponsored threads.
  • fn fin (&self, tag: InlinableString, fin: Box<dyn TTask>) -> bool Registers given task, if not already per tag, to be run (FIFO) on bye. FnOnce tasks complete immediately; TTask implementations returning Repeat run in stop.
  • fn jobsⁿ (&self) -> Re<usize> Number of jobs queued or running.
  • fn threadsⁿ (&self) -> usize Number of threads in the pool.
  • fn bye (&self) -> usize Signals threads to exit, runs finalizers, prevents new jobs from being posted.
  • fn stop (&self) -> usize Non-blocking stop: joins finished threads, runs fin timers.

Global Functions

  • fn tpool() -> Result<AReadGuard<'static, TPool, TPool>, AArcErr> Shared thread pool.
  • fn tpost (spin: u32, threads: u8, task: Box<dyn Task>) -> Re<bool> Posts task to shared TPOOL if threads are in it, or runs on current thread otherwise.

Dependencies

~0–12MB
~250K SLoC