https://github.com/michaelsproul/static_slice
Rust macro for static slices.
https://github.com/michaelsproul/static_slice
rust rust-macro
Last synced: about 1 year ago
JSON representation
Rust macro for static slices.
- Host: GitHub
- URL: https://github.com/michaelsproul/static_slice
- Owner: michaelsproul
- Created: 2015-01-17T22:08:58.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-04-05T00:00:13.000Z (about 9 years ago)
- Last Synced: 2024-10-07T17:20:16.896Z (over 1 year ago)
- Topics: rust, rust-macro
- Language: Rust
- Size: 1.95 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Static Slice
Rust macro for succinctly creating static slices.
## Usage
```rust
static_slice![: a1, a2, ..., an]
```
## Examples
```rust
let bytes = static_slice![u8: 1, 3, 5, 7, 8];
```
```rust
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.