Crates.io | posix-space |
lib.rs | posix-space |
version | 1.0.4 |
source | src |
created_at | 2022-08-13 05:15:45.997844 |
updated_at | 2023-06-02 17:40:57.610955 |
description | Pure Rust implementation of `isspace` for the POSIX locale |
homepage | https://github.com/artichoke/posix-space |
repository | https://github.com/artichoke/posix-space |
max_upload_size | |
id | 644474 |
size | 17,510 |
A small crate which determines if a byte is classified as a space in the POSIX locale per POSIX.1-2017, chapter 7, Locale.
space
Define characters to be classified as white-space characters.
In the POSIX locale, exactly <space>, <form-feed>, <newline>, <carriage-return>, <tab>, and <vertical-tab> shall be included.
The function defined in this crate should have equivalent behavior to the C
function isspace
as defined in ctype.h
.
Add this to your Cargo.toml
:
[dependencies]
posix-space = "1.0.4"
Then classify bytes like:
assert!(posix_space::is_space(b' '));
assert!(posix_space::is_space(b'\t'));
assert!(posix_space::is_space(b'\r'));
assert!(!posix_space::is_space(b'\0'));
assert!(!posix_space::is_space(b'C'));
assert!(!posix_space::is_space(b'&'));
This crate's behavior differs from u8::is_ascii_whitespace
in the Rust
standard library in that <vertical-tab>, \x0B
, is considered a space.
assert!(posix_space::is_space(b'\x0B'));
posix-space
is no_std
with no dependencies outside of Rust core
.
This crate requires at least Rust 1.31.0. This version can be bumped in minor releases.
posix-space
is licensed under the MIT License (c) Ryan Lopopolo.