1 unstable release

0.1.0 Apr 14, 2020

#30 in #checked

MIT license

4KB

ascii-literal

A proc-macro to make compile-time checked AsciiStrs.

Examples

This compiles just fine, and works as you would expect.

use ascii_literal::ascii_literal;
const MESSAGE: &ascii::AsciiStr = ascii_literal!("Hello in ASCII!");
println!("{}", MESSAGE); // Prints "Hello in ASCII!"

This, however, will give a compile time error.

use ascii_literal::ascii_literal;
// This doesn't compile!
const NOT_ASCII: &ascii::AsciiStr = ascii_literal!("Boom! 💥");

lib.rs:

A proc-macro to make compile-time checked AsciiStrs.

Provides the macro ascii_literal, which const-evaluates to an AsciiStr, checking for valid ASCII at compile time.

Dependencies

~1.5MB
~41K SLoC