#posix #locale #space #no-alloc #isspace

no-std posix-space

Pure Rust implementation of isspace for the POSIX locale

5 stable releases

1.0.4 Jun 2, 2023
1.0.3 Oct 6, 2022
1.0.2 Aug 13, 2022

#836 in Encoding

Download history 151/week @ 2024-11-20 272/week @ 2024-11-27 219/week @ 2024-12-04 226/week @ 2024-12-11 220/week @ 2024-12-18 328/week @ 2024-12-25 448/week @ 2025-01-01 159/week @ 2025-01-08 150/week @ 2025-01-15 146/week @ 2025-01-22 806/week @ 2025-01-29 387/week @ 2025-02-05 157/week @ 2025-02-12 222/week @ 2025-02-19 345/week @ 2025-02-26 286/week @ 2025-03-05

1,054 downloads per month

MIT license

17KB
311 lines

posix-space

GitHub Actions Code Coverage Discord Twitter
Crate API API trunk

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.

Usage

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'));

Crate features

posix-space is no_std with no dependencies outside of Rust core.

Minimum Supported Rust Version

This crate requires at least Rust 1.31.0. This version can be bumped in minor releases.

License

posix-space is licensed under the MIT License (c) Ryan Lopopolo.

No runtime deps