[Design] confusing `target_pointer_width = "64"` usize convertion design
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Title
confusing target_pointer_width = "64" usize convertion design
Actual
#[cfg(target_pointer_width = "64")]
{
let _ = usize::try_from(42u64).unwrap();
let _ = usize::try_from(42u32).unwrap();
let _ = usize::from(42u16);
}
Expected
When under target_pointer_width 64, should always success, and try is not necessary.
#[cfg(CONDITION)]
{
let _ = usize::from(42u64);
let _ = usize::from(42u32);
let _ = usize::from(42u16);
}
Related
https://github.com/rust-lang/rust/blob/master/library/core/src/convert/num.rs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read library/core/src/convert/num.rs and inspect the existing usize conversion implementations related to target_pointer_width. Compare the requested 64-bit behavior with the current conversion design and determine the appropriate condition and API implications. Done means the design is settled and the relevant conversions have consistent, justified behavior under the requested target width.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100