#peek #check #push #head #stack #link #node #support

list

A singly-linked stack like list support peek

4 releases

Uses old Rust 2015

0.1.3 May 26, 2017
0.1.2 May 26, 2017
0.1.1 May 26, 2017
0.1.0 May 26, 2017

#56 in #list

Download history 36/week @ 2023-10-26 33/week @ 2023-11-02 39/week @ 2023-11-09 35/week @ 2023-11-16 41/week @ 2023-11-23 38/week @ 2023-11-30 47/week @ 2023-12-07 31/week @ 2023-12-14 36/week @ 2023-12-21 32/week @ 2023-12-28 40/week @ 2024-01-04 32/week @ 2024-01-11 44/week @ 2024-01-18 38/week @ 2024-01-25 39/week @ 2024-02-01 46/week @ 2024-02-08

172 downloads per month

MIT license

6KB
141 lines

list

License Build Status crates.io doc.rs

A singly-linked stack like list support peek.

Getting started

Installing

Add this to Cargo.toml file of your project:

[dependencies]
list = "~0.1.1"

Usage

extern crate list;

use list::List;

fn main() {
    let mut list = List::new();
    // Check empty list behaves right
    assert_eq!(list.pop(), None);

    // Populate list
    list.push(1);
    list.push(2);
    list.push(3);

    // Check normal removal
    assert_eq!(list.pop(), Some(3));
    assert_eq!(list.pop(), Some(2));

    // Push some more just to make sure nothing's corrupted
    list.push(4);
    list.push(5);

    // Check normal removal
    assert_eq!(list.pop(), Some(5));
    assert_eq!(list.pop(), Some(4));

    // Check exhaustion
    assert_eq!(list.pop(), Some(1));
    assert_eq!(list.pop(), None);
}

Run test

cargo test -v

LICENSE

MIT

No runtime deps