#better #array #resizeable #analogy #🐍

sssstd

🐍 - A better analogy for resizeable arrays

3 releases

0.1.2 Feb 11, 2019
0.1.1 Feb 11, 2019
0.1.0 Feb 11, 2019

#2667 in Rust patterns

Download history 2/week @ 2024-07-01 22/week @ 2024-09-23 39/week @ 2024-09-30

61 downloads per month

MIT license

3KB

SSSSTD 🐍

The name Vector for a resizeable array of values easily causes confusion with mathematical vectors, snakes are a much better analogy for such a structure.

  • A snake occupies a finite continuous region of space
  • As a snake outgrows its capacity, it has to re-allocate. Biologists tend to refer to this as shedding skin.

Usage

use sssstd::snek::Snek;
#[macro_use]
use sssstd::macros;

fn main() {
    let snek = Snek::<i32>::new();
    snek.push(1);
    println!("{}", snek);

    let snek2 = snek!(1,2,3 as i32);
    println!("{}", snek2);
}

Advanced usage

If have non-ascii-idents enabled in your nightly compiler, you can also do this. A picture speaks a thousand words after all

use sssstd::snek::Snek;

fn main() {
    let 🐍 = Snek::<i32>::new();
    🐍.push(1);
    println!("{}", snek);
}

No runtime deps