Skip to content

thread::ThreadId Display missing #52780

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

Open
mitsuhiko opened this issue Jul 27, 2018 · 3 comments
Open

thread::ThreadId Display missing #52780

mitsuhiko opened this issue Jul 27, 2018 · 3 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@mitsuhiko
Copy link
Contributor

Currently the thread::ThreadId can only be debug rendered. That's not entirely great because it renders with the ThreadId() thing around. Right now to report the thread ID to sentry we transmute it so we can get the inner u64 out.

Would it be reasonable to have a Display implementation to get a nice string version of the integer in it? There is a bit of precedent for this in Rust: StatusCode in std::process can be displayed and so can be process IDs (which are just u32s).

@pietroalbini pietroalbini added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jul 27, 2018
@frewsxcv
Copy link
Member

This may or may not help you, but there's also this which lets you get the pthread_t out of a thread on unix platforms.

@sanmai-NL
Copy link

ThreadId does implement Debug, so printing them works somewhat. Can we also have u64 implement From<ThreadId>? Then programmers can do with the number as they like.

@Mark-Simulacrum
Copy link
Member

I would personally be against adding the Display impl (I think the one on ExitStatus was not the right move there) and instead provide a function that returns u64, as suggested by @sanmai-NL. It seems likely that thread ids on any platform can be converted to u64, and converting in the other direction seems not helpful.

@Mark-Simulacrum Mark-Simulacrum added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. 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

5 participants