-
Notifications
You must be signed in to change notification settings - Fork 701
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
Add conversion between span::Id
and NonZeroU64
#770
Conversation
This allows handling the 0 case separately and avoiding panicking within `Id::from_u64`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, thanks!
/// Constructs a new span ID from the given `NonZeroU64`. | ||
/// | ||
/// Unlike [`Id::from_u64`](#method.from_u64), this will never panic. | ||
#[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not convinced we need inline attributes for these --- I can't imagine them ever not being inlined. Not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the lack of #[inline]
in this crate. In my experience, not having the attribute results in a function call, which is needless overhead. However, I haven't tested whether this is the case for newer compilers. I remember seeing a compiler issue tracking this behavior.
It occurs to me that these could probably just be |
These conversions could definitely (and maybe should) be |
Yeah, I wasn't thinking we would make the Let's merge these with the more explicit name; we can always add |
Changed - Replaced use of `inner_local_macros` with `$crate::` (#729) Added - `must_use` warning to guards returned by `dispatcher::set_default` (#686) - `fmt::Debug` impl to `dyn Value`s (#696) - Functions to convert between `span::Id` and `NonZeroU64` (#770) - More obvious warnings in documentation (#769) Fixed - Compiler error when `tracing-core/std` feature is enabled but `tracing/std` is not (#760) - Clippy warning on vtable address comparison in `callsite::Identifier` (#749) - Documentation formatting issues (#715, #771) Thanks to @bkchr, @majecty, @taiki-e, @nagisa, and @nqvz for contributing to this release!
### Changed - Replaced use of `inner_local_macros` with `$crate::` (#729) ### Added - `must_use` warning to guards returned by `dispatcher::set_default` (#686) - `fmt::Debug` impl to `dyn Value`s (#696) - Functions to convert between `span::Id` and `NonZeroU64` (#770) - More obvious warnings in documentation (#769) ### Fixed - Compiler error when `tracing-core/std` feature is enabled but `tracing/std` is not (#760) - Clippy warning on vtable address comparison in `callsite::Identifier` (#749) - Documentation formatting issues (#715, #771) Thanks to @bkchr, @majecty, @taiki-e, @nagisa, and @nvzqz for contributing to this release!
Motivation
Consumers of the crate should be able to handle the 0 case separately and avoiding panicking within
Id::from_u64
.Solution
Expose direct conversion between the inner type.