ascii/
lib.rs

1// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11//! A library that provides ASCII-only string and character types, equivalent to the `char`, `str`
12//! and `String` types in the standard library.
13//!
14//! Please refer to the readme file to learn about the different feature modes of this crate.
15//!
16//! # Minimum supported Rust version
17//!
18//! The minimum Rust version for 1.1.\* releases is 1.41.1.
19//! Later 1.y.0 releases might require newer Rust versions, but the three most
20//! recent stable releases at the time of publishing will always be supported.  
21//! For example this means that if the current stable Rust version is 1.70 when
22//! ascii 1.2.0 is released, then ascii 1.2.\* will not require a newer
23//! Rust version than 1.68.
24//!
25//! # History
26//!
27//! This package included the Ascii types that were removed from the Rust standard library by the
28//! 2014-12 [reform of the `std::ascii` module](https://github.com/rust-lang/rfcs/pull/486). The
29//! API changed significantly since then.
30
31#![cfg_attr(not(feature = "std"), no_std)]
32// Clippy lints
33#![warn(
34    clippy::pedantic,
35    clippy::decimal_literal_representation,
36    clippy::get_unwrap,
37    clippy::indexing_slicing
38)]
39// Naming conventions sometimes go against this lint
40#![allow(clippy::module_name_repetitions)]
41// We need to get literal non-asciis for tests
42#![allow(clippy::non_ascii_literal)]
43// Sometimes it looks better to invert the order, such as when the `else` block is small
44#![allow(clippy::if_not_else)]
45// Shadowing is common and doesn't affect understanding
46// TODO: Consider removing `shadow_unrelated`, as it can show some actual logic errors
47#![allow(clippy::shadow_unrelated, clippy::shadow_reuse, clippy::shadow_same)]
48// A `if let` / `else` sometimes looks better than using iterator adaptors
49#![allow(clippy::option_if_let_else)]
50// In tests, we're fine with indexing, since a panic is a failure.
51#![cfg_attr(test, allow(clippy::indexing_slicing))]
52// for compatibility with methods on char and u8
53#![allow(clippy::trivially_copy_pass_by_ref)]
54// In preparation for feature `unsafe_block_in_unsafe_fn` (https://github.com/rust-lang/rust/issues/71668)
55#![allow(unused_unsafe)]
56
57#[cfg(feature = "alloc")]
58#[macro_use]
59extern crate alloc;
60#[cfg(feature = "std")]
61extern crate core;
62
63#[cfg(feature = "serde")]
64extern crate serde;
65
66#[cfg(all(test, feature = "serde_test"))]
67extern crate serde_test;
68
69mod ascii_char;
70mod ascii_str;
71#[cfg(feature = "alloc")]
72mod ascii_string;
73mod free_functions;
74#[cfg(feature = "serde")]
75mod serialization;
76
77pub use ascii_char::{AsciiChar, ToAsciiChar, ToAsciiCharError};
78pub use ascii_str::{AsAsciiStr, AsAsciiStrError, AsMutAsciiStr, AsciiStr};
79pub use ascii_str::{Chars, CharsMut, CharsRef};
80#[cfg(feature = "alloc")]
81pub use ascii_string::{AsciiString, FromAsciiError, IntoAsciiString};
82pub use free_functions::{caret_decode, caret_encode};