devela::_dep::const_str

Macro is_ascii

macro_rules! is_ascii {
    ($s:expr) => { ... };
}
Available on crate feature dep_const_str only.
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
};