6 releases (3 stable)

1.1.1 Jun 30, 2023
1.1.0 Jan 13, 2021
1.0.0 Apr 25, 2020
0.99.0 Apr 11, 2020
0.99.0-dev.3 Mar 26, 2020

#66 in Text processing

Download history 30028/week @ 2023-12-12 26254/week @ 2023-12-19 18028/week @ 2023-12-26 31517/week @ 2024-01-02 36960/week @ 2024-01-09 38212/week @ 2024-01-16 39117/week @ 2024-01-23 42777/week @ 2024-01-30 45617/week @ 2024-02-06 48181/week @ 2024-02-13 46596/week @ 2024-02-20 47322/week @ 2024-02-27 51575/week @ 2024-03-05 51499/week @ 2024-03-12 53316/week @ 2024-03-19 43477/week @ 2024-03-26

207,336 downloads per month
Used in 238 crates (27 directly)

MIT/Apache

24KB
430 lines

text-size

Build Status Crates.io API reference

A library that provides newtype wrappers for u32 and (u32, u32) for use as text offsets.

See the docs for more.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Newtypes for working with text sizes/ranges in a more type-safe manner.

This library can help with two things:

  • Reducing storage requirements for offsets and ranges, under the assumption that 32 bits is enough.
  • Providing standard vocabulary types for applications where text ranges are pervasive.

However, you should not use this library simply because you work with strings. In the overwhelming majority of cases, using usize and std::ops::Range<usize> is better. In particular, if you are publishing a library, using only std types in the interface would make it more interoperable. Similarly, if you are writing something like a lexer, which produces, but does not store text ranges, then sticking to usize would be better.

Minimal Supported Rust Version: latest stable.

Dependencies

~180KB