https://github.com/niklasf/rust-btoi
Parse integers directly from ASCII byte slices
https://github.com/niklasf/rust-btoi
c rust
Last synced: 3 months ago
JSON representation
Parse integers directly from ASCII byte slices
- Host: GitHub
- URL: https://github.com/niklasf/rust-btoi
- Owner: niklasf
- License: apache-2.0
- Created: 2017-09-29T16:44:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-07T20:37:15.000Z (6 months ago)
- Last Synced: 2025-04-12T21:07:21.576Z (3 months ago)
- Topics: c, rust
- Language: Rust
- Homepage: https://docs.rs/btoi
- Size: 89.8 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
btoi
====Parse integers from ASCII byte slices.
[](https://crates.io/crates/btoi)
[](https://docs.rs/btoi)Introduction
------------Provides functions similar to [`from_str_radix`](https://doc.rust-lang.org/std/primitive.u32.html#method.from_str_radix),
but is faster when parsing directly from byte slices instead of strings.Supports `#![no_std]`.
```rust
use btoi::btoi;assert_eq!(Ok(42), btoi(b"42"));
assert_eq!(Ok(-1000), btoi(b"-1000"));
```Documentation
-------------[Read the documentation](https://docs.rs/btoi)
MSRV policy
-----------The minimum supported Rust version is 1.60, matching
[`num_traits`](https://crates.io/crates/num-traits),
with no intent to ever increase it.That's because
[`#![feature(int_from_ascii)]`](https://github.com/rust-lang/rust/issues/134821)
in the standard library will hopefully eventually make this crate obsolete
for new versions of Rust, and so old versions are the priority.Changelog
---------* 0.4.4 (yanked due to unintended MSRV bump)
- Implement `core::error::Error` for `ParseIntegerError`.
* 0.4.3
- Use `#[track_caller]`.
* 0.4.2
- No longer `!#[deny(warnings)]`, which is is a forwards compability hazard
in libraries.
- Explicit `!#[forbid(unsafe_code)]`.
* 0.4.1
- `-` was parsed as zero, but should have errored. Thanks @wayslog.
* 0.4.0
- Change type of radix to `u32` (from `u8`) to mirror the standard library.
- No need to `#[inline]` generic functions.
* 0.3.0
- New default feature `std`. Disable for `#![no_std]` support.
- Mark functions as `#[inline]`.
* 0.2.0
- No longer reexport num-traits.
* 0.1.3
- Update to num-traits 0.2 (semver compatible).
* 0.1.2
- Fix documentation warnings.
- Update dependencies.
* 0.1.1
- Documentation fixes.
* 0.1.0
- Initial release.License
-------btoi is dual licensed under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
and [MIT](http://opensource.org/licenses/MIT) license, at your option.