# libs

**URL:** https://internals.rust-lang.org/c/libs/13.md?page=3

[Latest](https://internals.rust-lang.org/latest.md) · [Categories](https://internals.rust-lang.org/categories.md)

**Page:** 4

---

## [Feature Request: Integer Trait](https://internals.rust-lang.org/t/feature-request-integer-trait/23112)

<div class="topic-metadata">

**Author:** [@SciMind2460](https://internals.rust-lang.org/u/SciMind2460)\
**Replies:** 2\
**Last updated:** [June 23, 2025, 4:13pm UTC](https://internals.rust-lang.org/t/feature-request-integer-trait/23112 "2025-06-23T16:13:40Z")

</div>

Sometimes we wish to generalise an implementation of a trait over many integer types, and applying them one by one becomes too cumbersome. In the vein of generalising integers, I propose the Int, SignedInt and UnsignedIn…

---

## [Add \`map\` for \`NonZero\` types?](https://internals.rust-lang.org/t/add-map-for-nonzero-types/23091)

<div class="topic-metadata">

**Author:** [@tesfabpel](https://internals.rust-lang.org/u/tesfabpel)\
**Replies:** 1\
**Last updated:** [June 14, 2025, 12:43pm UTC](https://internals.rust-lang.org/t/add-map-for-nonzero-types/23091 "2025-06-14T12:43:10Z")

</div>

Hi, I thought it may be worthy to add a map function for NonZero\<T\> types... I imagine such function would be more or less like this: pub fn map\<U, F\>(self, f: F) -\> Option\<NonZero\<U\>\> where F: FnOnce(T) -\> …

---

## [\#\[derive(Display("({x}, {y})"))\]](https://internals.rust-lang.org/t/derive-display-x-y/23026)

<div class="topic-metadata">

**Author:** [@Dwarsloeper](https://internals.rust-lang.org/u/Dwarsloeper)\
**Replies:** 5\
**Last updated:** [June 2, 2025, 12:23pm UTC](https://internals.rust-lang.org/t/derive-display-x-y/23026 "2025-06-02T12:23:10Z")

</div>

While it is nice to get Debug derived, sadly the same is not true for the similar Display. Now obviously there is no canonical right implementation, but often only the inner part of five lines varies. So I propose this: …

---

## [Allow detecting if Instant::now is actually supported by the platform](https://internals.rust-lang.org/t/allow-detecting-if-instant-now-is-actually-supported-by-the-platform/22974)

<div class="topic-metadata">

**Author:** [@rcoh](https://internals.rust-lang.org/u/rcoh)\
**Replies:** 11\
**Last updated:** [May 25, 2025, 8:07am UTC](https://internals.rust-lang.org/t/allow-detecting-if-instant-now-is-actually-supported-by-the-platform/22974 "2025-05-25T08:07:34Z")

</div>

There have been some recent issues in Tokio as metrics are stabilized that start calling Instant::now in general purpose code paths. The problem is that there isn't actually a way to tell if Instant::now is going to pan…

---

## [BijectionMap (Pre-RFC)](https://internals.rust-lang.org/t/bijectionmap-pre-rfc/22950)

<div class="topic-metadata">

**Author:** [@SciMind2460](https://internals.rust-lang.org/u/SciMind2460)\
**Replies:** 15\
**Last updated:** [May 24, 2025, 12:57pm UTC](https://internals.rust-lang.org/t/bijectionmap-pre-rfc/22950 "2025-05-24T12:57:01Z")

</div>

Summary This RFC suggests a new data structure for Rust, to be implemented later: A Bi-Directional HashMap, or BijectionMap\<K, V, S\> where both the key and value are hashable and can be looked up. Additionaly, a Trijecti…

---

## [std::io::ErrorKind::NotFound error message: add filename](https://internals.rust-lang.org/t/std-notfound-error-message-add-filename/22941)

<div class="topic-metadata">

**Author:** [@KonradHoeffner](https://internals.rust-lang.org/u/KonradHoeffner)\
**Replies:** 7\
**Last updated:** [May 21, 2025, 10:41am UTC](https://internals.rust-lang.org/t/std-notfound-error-message-add-filename/22941 "2025-05-21T10:41:25Z")

</div>

When you open a file that does not exist you get an appropriate NotFound error kind, however the message "No such file or directory" is missing the name of the file or directory that is missing. If your program is loadin…

---

## [Div&mod for \`NonZero\<T\>\` - is it worth ACP?](https://internals.rust-lang.org/t/div-mod-for-nonzero-t-is-it-worth-acp/22912)

<div class="topic-metadata">

**Author:** [@Kixunil](https://internals.rust-lang.org/u/Kixunil)\
**Replies:** 2\
**Last updated:** [May 13, 2025, 4:10pm UTC](https://internals.rust-lang.org/t/div-mod-for-nonzero-t-is-it-worth-acp/22912 "2025-05-13T16:10:34Z")

</div>

I've noticed that if you divide a non-zero x which is divisible by y then the result is never zero. Suggesting this API: impl\<T: Div + Mod\> NonZero\<T\> { fn div\_mod(self, divisor: NonZero\<T\>) -\> DivModResult { …

---

## [Array::map annotate with #\[must\_use\]](https://internals.rust-lang.org/t/array-map-annotate-with-must-use/22813)

<div class="topic-metadata">

**Author:** [@JulianKnodt](https://internals.rust-lang.org/u/JulianKnodt)\
**Replies:** 25\
**Last updated:** [May 12, 2025, 5:39am UTC](https://internals.rust-lang.org/t/array-map-annotate-with-must-use/22813 "2025-05-12T05:39:15Z")

</div>

Hi, I frequently call Array::map, and occasionally find that I will map an array, and forget to use the output when the underlying type is Copy. I was thinking it makes sense to annotate Array::map with #\[must\_use\], whic…

---

## [An alternative to Rc::new\_cyclic](https://internals.rust-lang.org/t/an-alternative-to-rc-new-cyclic/22849)

<div class="topic-metadata">

**Author:** [@Kainaik1](https://internals.rust-lang.org/u/Kainaik1)\
**Replies:** 9\
**Last updated:** [May 6, 2025, 10:53am UTC](https://internals.rust-lang.org/t/an-alternative-to-rc-new-cyclic/22849 "2025-05-06T10:53:03Z")

</div>

I posted this reddit thread and was referred here. I'm wondering about natively supporting initialization of Weak at a later point, instead of inside Rc::new\_cyclic's data\_fn. I propose this to look something like the f…

---

## [(Read-only) access to crate code in proc-macro](https://internals.rust-lang.org/t/read-only-access-to-crate-code-in-proc-macro/22715)

<div class="topic-metadata">

**Author:** [@Ruttie](https://internals.rust-lang.org/u/Ruttie)\
**Replies:** 6\
**Last updated:** [April 8, 2025, 9:39pm UTC](https://internals.rust-lang.org/t/read-only-access-to-crate-code-in-proc-macro/22715 "2025-04-08T21:39:23Z")

</div>

Currently proc-macros can only access the code they are applied to. It would be nice if proc-macros could access the entire crate's code, possibly in a read-only state. This is similar to C# source-generators, though add…

---

## [Redoing hashing traits](https://internals.rust-lang.org/t/redoing-hashing-traits/22707)

<div class="topic-metadata">

**Author:** [@programmerjake](https://internals.rust-lang.org/u/programmerjake)\
**Replies:** 3\
**Last updated:** [April 8, 2025, 2:05pm UTC](https://internals.rust-lang.org/t/redoing-hashing-traits/22707 "2025-04-08T14:05:15Z")

</div>

The current Hash and Hasher traits have some flaws: Hasher isn't really usable for order independent hashing, as is needed for impl Hash for HashSet and other types that act like sets or bags that don't have a good way…

---

## [Would it ever be possible to add a blanket implementations like this to stdlib?](https://internals.rust-lang.org/t/would-it-ever-be-possible-to-add-a-blanket-implementations-like-this-to-stdlib/22694)

<div class="topic-metadata">

**Author:** [@HjVT](https://internals.rust-lang.org/u/HjVT)\
**Replies:** 3\
**Last updated:** [April 7, 2025, 6:18pm UTC](https://internals.rust-lang.org/t/would-it-ever-be-possible-to-add-a-blanket-implementations-like-this-to-stdlib/22694 "2025-04-07T18:18:49Z")

</div>

impl\<A, B\> \[Try\]From\<A\> for Option\<B\> where B: \[Try\]From\<A\> It certainly ia not an infrequent occurrence to perform an operation like that, but while in normal code it is possible to just map the container type, it is n…

---

## [Discussion: Distinct Phantom types for different traits](https://internals.rust-lang.org/t/discussion-distinct-phantom-types-for-different-traits/22654)

<div class="topic-metadata">

**Author:** [@joshlf](https://internals.rust-lang.org/u/joshlf)\
**Replies:** 9\
**Last updated:** [April 1, 2025, 6:22pm UTC](https://internals.rust-lang.org/t/discussion-distinct-phantom-types-for-different-traits/22654 "2025-04-01T18:22:27Z")

</div>

Following up on this discussion thread on the NoCell/Freeze RFC. How would we feel about moving in a direction in which we have distinct PhantomXxx types for different behavior? I.e.: // These opt out of auto traits. \`…

---

## [\`GlobalAlloc::dealloc\` is too restrictive, provide additional method with weaker requirements](https://internals.rust-lang.org/t/globalalloc-dealloc-is-too-restrictive-provide-additional-method-with-weaker-requirements/22620)

<div class="topic-metadata">

**Author:** [@Sol-Ell](https://internals.rust-lang.org/u/Sol-Ell)\
**Replies:** 6\
**Last updated:** [March 25, 2025, 7:02pm UTC](https://internals.rust-lang.org/t/globalalloc-dealloc-is-too-restrictive-provide-additional-method-with-weaker-requirements/22620 "2025-03-25T19:02:10Z")

</div>

GlobalAlloc::dealloc states that the provided memory layout must be the same as the layout used to allocate the memory block. This implies that the alignment of these two layouts must be identical. However, doesn't the …

---

## [Naming \`bigint\_helper\_methods\` (bike-shedding)](https://internals.rust-lang.org/t/naming-bigint-helper-methods-bike-shedding/21688)

<div class="topic-metadata">

**Author:** [@Rudxain](https://internals.rust-lang.org/u/Rudxain)\
**Replies:** 15\
**Last updated:** [March 23, 2025, 7:27pm UTC](https://internals.rust-lang.org/t/naming-bigint-helper-methods-bike-shedding/21688 "2025-03-23T19:27:57Z")

</div>

Context I've created this topic for the discussion of naming those methods. Addition: carrying\_add seems fine. extending\_add is ok, but seems misleadingly similar to widening\_add overflowing\_add\_carry seems descripti…

---

## [Idea: new read method on std::io::Read trait that continues when interrupted](https://internals.rust-lang.org/t/idea-new-read-method-on-std-read-trait-that-continues-when-interrupted/22624)

<div class="topic-metadata">

**Author:** [@HEnquist](https://internals.rust-lang.org/u/HEnquist)\
**Replies:** 5\
**Last updated:** [March 22, 2025, 10:33pm UTC](https://internals.rust-lang.org/t/idea-new-read-method-on-std-read-trait-that-continues-when-interrupted/22624 "2025-03-22T22:33:41Z")

</div>

It has happened now several times that I have needed a method that is something like a mix of the Read::read() and Read::read\_exact() methods. What I want is to read up to N bytes from a Read object, and get less than N …

---

## [From/Into arrays for core::arch SIMD types?](https://internals.rust-lang.org/t/from-into-arrays-for-core-arch-simd-types/22555)

<div class="topic-metadata">

**Author:** [@kornel](https://internals.rust-lang.org/u/kornel)\
**Replies:** 1\
**Last updated:** [March 14, 2025, 5:50pm UTC](https://internals.rust-lang.org/t/from-into-arrays-for-core-arch-simd-types/22555 "2025-03-14T17:50:15Z")

</div>

Currently it's cumbersome to get data in or out of non-portable SIMD types like \_\_m128 or float32x4\_t. The load/store intrinsics require raw pointers like \*const f32, which needs a combo of .as\_ptr().cast(). Having a \*…

---

## [Idea: Per edition reclaiming of crates.io crate names](https://internals.rust-lang.org/t/idea-per-edition-reclaiming-of-crates-io-crate-names/22561)

<div class="topic-metadata">

**Author:** [@crlf0710](https://internals.rust-lang.org/u/crlf0710)\
**Replies:** 10\
**Last updated:** [March 17, 2025, 11:05pm UTC](https://internals.rust-lang.org/t/idea-per-edition-reclaiming-of-crates-io-crate-names/22561 "2025-03-17T23:05:51Z")

</div>

Recently with the new policy, the crates.io has removed lots of empty crates from crates.io, which definitely is useful and has made the overall crates.io name squatting issue less severe. I think maybe it's time for pla…

---

## [Pre-RFC: Trait for Coercion of untyped numeric literals](https://internals.rust-lang.org/t/pre-rfc-trait-for-coercion-of-untyped-numeric-literals/22520)

<div class="topic-metadata">

**Author:** [@nik-rev](https://internals.rust-lang.org/u/nik-rev)\
**Replies:** 8\
**Last updated:** [March 13, 2025, 12:17am UTC](https://internals.rust-lang.org/t/pre-rfc-trait-for-coercion-of-untyped-numeric-literals/22520 "2025-03-13T00:17:35Z")

</div>

You can create NonZero numeric types and check at compile time that they are in fact, nonzero like so: const { NonZeroU8::new(4).unwrap() } But, it requires using a const block and an unwrap. It would be great to be ab…

---

## [Pre-RFC: std::cmp::NoOrder](https://internals.rust-lang.org/t/pre-rfc-std-noorder/22514)

<div class="topic-metadata">

**Author:** [@VincentLagerros](https://internals.rust-lang.org/u/VincentLagerros)\
**Replies:** 21\
**Last updated:** [March 12, 2025, 3:05pm UTC](https://internals.rust-lang.org/t/pre-rfc-std-noorder/22514 "2025-03-12T15:05:25Z")

</div>

When working with some data structures like BinaryHeap with tuples, I might only wanted to sort by the first value, but no not care about the second (like sort by score with name as data BinaryHeap::\<(u32,String)\>). This…

---

## [\`Vec::rdedup(\_by(\_key))\`?](https://internals.rust-lang.org/t/vec-rdedup-by-key/22533)

<div class="topic-metadata">

**Author:** [@Jisu-Woniu](https://internals.rust-lang.org/u/Jisu-Woniu)\
**Replies:** 7\
**Last updated:** [March 11, 2025, 3:52am UTC](https://internals.rust-lang.org/t/vec-rdedup-by-key/22533 "2025-03-11T03:52:27Z")

</div>

Vec::dedup related methods "removes all but the first of consecutive elements in the vector". Is there a need for a method removes all but the last equal items?

---

## [IPv6 Zone ID Comparison](https://internals.rust-lang.org/t/ipv6-zone-id-comparison/22481)

<div class="topic-metadata">

**Author:** [@mustartt](https://internals.rust-lang.org/u/mustartt)\
**Replies:** 2\
**Last updated:** [March 1, 2025, 11:49am UTC](https://internals.rust-lang.org/t/ipv6-zone-id-comparison/22481 "2025-03-01T11:49:17Z")

</div>

We are noticing a failing assert in the stdlib when using Socket::recv\_from. Due to the interface being a link-local address, the OS may insert a zone index which in some cases will cause mismatches. I'm wondering if it …

---

## [Vec is asymmetric with memory handling](https://internals.rust-lang.org/t/vec-is-asymmetric-with-memory-handling/22449)

<div class="topic-metadata">

**Author:** [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Replies:** 38\
**Last updated:** [February 25, 2025, 8:22pm UTC](https://internals.rust-lang.org/t/vec-is-asymmetric-with-memory-handling/22449 "2025-02-25T20:22:32Z")

</div>

This thread is hosting the discussion split from the following section of a reply from @tczajka in What is the purpose of std? - #9 by tczajka

---

## [Implement \`NonZero::from\_str\_radix\`](https://internals.rust-lang.org/t/implement-nonzero-from-str-radix/22464)

<div class="topic-metadata">

**Author:** [@sorairolake](https://internals.rust-lang.org/u/sorairolake)\
**Replies:** 0\
**Last updated:** [February 25, 2025, 6:19am UTC](https://internals.rust-lang.org/t/implement-nonzero-from-str-radix/22464 "2025-02-25T06:19:36Z")

</div>

NonZero::\<T\>::from\_str is already implemented. This only supports decimal, just like integer\_type::from\_str. For example, to convert a string which represents a hexadecimal number, we need to do something like this: le…

---

## [Bit-set as part of standard library](https://internals.rust-lang.org/t/bit-set-as-part-of-standard-library/22432)

<div class="topic-metadata">

**Author:** [@DoomSlayer](https://internals.rust-lang.org/u/DoomSlayer)\
**Replies:** 8\
**Last updated:** [February 22, 2025, 5:09am UTC](https://internals.rust-lang.org/t/bit-set-as-part-of-standard-library/22432 "2025-02-22T05:09:36Z")

</div>

If the Rust foundation wants widespread adoption, it should make bit-set part of the standard library. Having a commonly used type in the leading language for competitive programming, C++, hidden behind a crate in Rust m…

---

## [OS-Specific Extensions for creating Instant](https://internals.rust-lang.org/t/os-specific-extensions-for-creating-instant/22408)

<div class="topic-metadata">

**Author:** [@recatek](https://internals.rust-lang.org/u/recatek)\
**Replies:** 20\
**Last updated:** [February 21, 2025, 9:15pm UTC](https://internals.rust-lang.org/t/os-specific-extensions-for-creating-instant/22408 "2025-02-21T21:15:22Z")

</div>

I'm working with OS-level UDP packet timestamps in FreeBSD. In general this is a feature (SO\_TIMESTAMP) in some operating systems that lets you access the time that the OS received a packet -- as opposed to when your app…

---

## [Vec::grow\_to](https://internals.rust-lang.org/t/vec-grow-to/22416)

<div class="topic-metadata">

**Author:** [@recatek](https://internals.rust-lang.org/u/recatek)\
**Replies:** 4\
**Last updated:** [February 21, 2025, 3:04am UTC](https://internals.rust-lang.org/t/vec-grow-to/22416 "2025-02-21T03:04:04Z")

</div>

Surprised I couldn't find any discussion on this, so feel free to direct me to it if it exists. Is there a specific reason why Vec (and String, VecDeque, etc.) never got a grow\_to function? There are good reasons why the…

---

## [Missing String-\>CString without copy](https://internals.rust-lang.org/t/missing-string-cstring-without-copy/22379)

<div class="topic-metadata">

**Author:** [@nyurik](https://internals.rust-lang.org/u/nyurik)\
**Replies:** 12\
**Last updated:** [February 17, 2025, 9:19am UTC](https://internals.rust-lang.org/t/missing-string-cstring-without-copy/22379 "2025-02-17T09:19:00Z")

</div>

We have a impl TryFrom\<CString\> for String, but there is no impl TryFrom\<String\> for CString. The later is badly needed because it would allow converting Strings into CStrings almost always without an extra re-allocation…

---

## [Cross compile libcore](https://internals.rust-lang.org/t/cross-compile-libcore/22372)

<div class="topic-metadata">

**Author:** [@ARK](https://internals.rust-lang.org/u/ARK)\
**Replies:** 2\
**Last updated:** [February 12, 2025, 1:05pm UTC](https://internals.rust-lang.org/t/cross-compile-libcore/22372 "2025-02-12T13:05:03Z")

</div>

Hi Rust beginner here. I am trying create a custom target for RISC-V architecture, I would like to build the core library and share it as precompiled library. I was successful in compiling the core library for custom t…

---

## [Planned CStr changes seem inefficient](https://internals.rust-lang.org/t/planned-cstr-changes-seem-inefficient/22332)

<div class="topic-metadata">

**Author:** [@zackw](https://internals.rust-lang.org/u/zackw)\
**Replies:** 38\
**Last updated:** [February 10, 2025, 11:26pm UTC](https://internals.rust-lang.org/t/planned-cstr-changes-seem-inefficient/22332 "2025-02-10T23:26:39Z")

</div>

For a long time there have been warnings in the documentation of ffi::CStr that say that certain methods are constant-time now, but in the future they will do a strlen operation. For example, CStr::to\_bytes: Note: Thi…

[Previous page](https://internals.rust-lang.org/c/libs/13.md?page=2)

[Next page](https://internals.rust-lang.org/c/libs/13.md?page=4)
