Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for int_from_ascii #134821

Open
2 of 5 tasks
niklasf opened this issue Dec 27, 2024 · 1 comment
Open
2 of 5 tasks

Tracking Issue for int_from_ascii #134821

niklasf opened this issue Dec 27, 2024 · 1 comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@niklasf
Copy link
Contributor

niklasf commented Dec 27, 2024

Feature gate: #![feature(int_from_ascii)]

This is a tracking issue for int_from_ascii, providing equivalent methods to {usize,u8,u16,u32,u64,u128,isize,i8,i16,i32,i64,i128}::from_str() and from_str_radix() that allow working directly on byte slices, in order to skip UTF-8 validation.

Public API

For each integer type T (usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128):

// core::num

impl T {
    pub const fn from_ascii(src: &[u8]) -> Result<T, ParseIntError>;
    pub const fn from_ascii_radix(src: &[u8], radix: u32) -> Result<T, ParseIntError>;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@niklasf niklasf added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 27, 2024
@niklasf
Copy link
Contributor Author

niklasf commented Dec 27, 2024

Opened PR #134824 with an implementation.

niklasf added a commit to niklasf/rust that referenced this issue Dec 27, 2024
Provides unstable `T::from_ascii()` and `T::from_ascii_radix()` for integer
types `T`, as drafted in tracking issue rust-lang#134821.

To deduplicate documentation without additional macros, implementations of
`isize` and `usize` no longer delegate to equivalent integer types.
After rust-lang#132870 they are inlined anyway.
niklasf added a commit to niklasf/rust that referenced this issue Dec 27, 2024
Provides unstable `T::from_ascii()` and `T::from_ascii_radix()` for integer
types `T`, as drafted in tracking issue rust-lang#134821.

To deduplicate documentation without additional macros, implementations of
`isize` and `usize` no longer delegate to equivalent integer types.
After rust-lang#132870 they are inlined anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant