Macro const_str::is_ascii

source ·
macro_rules! is_ascii {
    ($s:expr) => { ... };
}
Expand description

Checks if all characters in this (string) slice are within the ASCII range.

The input type must be one of:

§Examples

const S1: &str = "hello!\n";
const S2: &str = "你好!";

const _: () = {
    assert!(const_str::is_ascii!(S1));              // true
    assert!(!const_str::is_ascii!(S2));             // false
    assert!(!const_str::is_ascii!(b"\x80\x00"));    // false
};