1//! Newtypes for working with text sizes/ranges in a more type-safe manner.
2//!
3//! This library can help with two things:
4//! * Reducing storage requirements for offsets and ranges, under the
5//! assumption that 32 bits is enough.
6//! * Providing standard vocabulary types for applications where text ranges
7//! are pervasive.
8//!
9//! However, you should not use this library simply because you work with
10//! strings. In the overwhelming majority of cases, using `usize` and
11//! `std::ops::Range<usize>` is better. In particular, if you are publishing a
12//! library, using only std types in the interface would make it more
13//! interoperable. Similarly, if you are writing something like a lexer, which
14//! produces, but does not *store* text ranges, then sticking to `usize` would
15//! be better.
16//!
17//! Minimal Supported Rust Version: latest stable.
18
19#![forbid(unsafe_code)]
20#![warn(missing_debug_implementations, missing_docs)]
21
22mod range;
23mod size;
24mod traits;
25
26#[cfg(feature = "serde")]
27mod serde_impls;
28
29pub use crate::{range::TextRange, size::TextSize, traits::TextLen};
30
31#[cfg(target_pointer_width = "16")]
32compile_error!("text-size assumes usize >= u32 and does not work on 16-bit targets");
33