Skip to content

Convert string literals to static unsigned integer slices in compile time.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

yangby-cryptape/rust-slices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust-Slices

License GitHub Actions Crate Badge Crate Doc MSRV 1.45.0

Convert string literals to static unsigned integer slices in compile time.

Usage

The input is a hexadecimal string literal with 0x prefix. The size of input should be an even number.

And you can use any number of _ in the string literal to separate it for more readable.

Examples

use slices::u8_slice;

const VAL: &[u8] = u8_slice!("0x_1234_5678_9abc_def0");
const NULL: &[u8] = u8_slice!("0x");

fn main () {
    let val = &[0x12u8, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0];
    assert_eq!(VAL, val);
    assert_eq!(NULL, &[]);
}

Minimum Supported Rust Version

Rust 1.45.0.

License

Licensed under either of Apache License, Version 2.0 or MIT License, at your option.

About

Convert string literals to static unsigned integer slices in compile time.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages