posix_space

Function is_space

Source
pub fn is_space(byte: u8) -> bool
Expand description

Determine whether the given byte is in space POSIX character class.

In the POSIX locale, exactly <space>, <form-feed>, <newline>, <carriage-return>, <tab>, and <vertical-tab> shall be included.

§Compatibility

This function differs from u8::is_ascii_whitespace in that <vertical-tab>, \x0B, is considered a space.

§Examples

assert!(posix_space::is_space(b' '));
assert!(posix_space::is_space(b'\x0C'));
assert!(posix_space::is_space(b'\n'));
assert!(posix_space::is_space(b'\r'));
assert!(posix_space::is_space(b'\t'));
assert!(posix_space::is_space(b'\x0B'));

Other ASCII characters are not POSIX spaces:

assert!(!posix_space::is_space(b'C'));
assert!(!posix_space::is_space(b'&'));
assert!(!posix_space::is_space(b'\x7F'));

Non-ASCII bytes are not POSIX spaces:

assert!(!posix_space::is_space(b'\x80'));
assert!(!posix_space::is_space(b'\xFF'));