#slice #static #macro #arbitrary-types

static_slice

Macro for creating static slices of arbitrary types

3 releases

Uses old Rust 2015

0.0.3 Apr 4, 2017
0.0.2 Apr 3, 2015
0.0.1 Jan 17, 2015

#4 in #arbitrary-types

Download history 357/week @ 2025-07-28 267/week @ 2025-08-04 500/week @ 2025-08-11 438/week @ 2025-08-18 440/week @ 2025-08-25 551/week @ 2025-09-01 847/week @ 2025-09-08 511/week @ 2025-09-15 739/week @ 2025-09-22 617/week @ 2025-09-29 547/week @ 2025-10-06 521/week @ 2025-10-13 725/week @ 2025-10-20 848/week @ 2025-10-27 1032/week @ 2025-11-03 666/week @ 2025-11-10

3,363 downloads per month
Used in 8 crates (via i2p_snow)

WTFPL license

2KB

Static Slice

Rust macro for succinctly creating static slices.

Usage

static_slice![<type>: a1, a2, ..., an]

Examples

let bytes = static_slice![u8: 1, 3, 5, 7, 8];
enum TruthValue {
    Yes,
    Maybe,
    No
}

fn to_bools(x: TruthValue) -> &'static [bool] {
    match x {
        Yes => static_slice![true],
        Maybe => static_slice![true, false],
        No => static_slice![false]
    }
}

License

Public domain. Go for it.

No runtime deps