Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
misc/metrics: Add
protocols
label to address-specific metrics #2982misc/metrics: Add
protocols
label to address-specific metrics #2982Changes from 16 commits
d7c0f89
3345407
32d5eb0
d815970
14e906a
808c439
4842a64
9c6b300
f165e01
b2c74ed
50c8bb5
d74e7e5
e5974ca
1d13413
3900f69
9a227ca
b618cf8
16c802b
6a5a593
6983a59
c8bcc82
ece8c9b
db1bcdc
0f6bdd1
f787368
0d3ec5b
7176f14
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why not implement
From
forLabel
?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 think we had this at some point and I recommended to move away from it. Unless we are actually using
From
as an abstraction somewhere, using a generic function has downsides in terms of clarity. It also encourages the use of.into
at callsites which makes it hard to see, what this is actually being converted into.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.
Ah yes, that sounds familiar. I probably resolved & hid the comment when I committed the recommended change, but it's probably still above somewhere.
Personally I think I prefer the From approach in this case - since the struct has such an incredibly narrow usage I don't think there's too much confusion about what
into
is doing. But of course I'll go with whatever the consensus is.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.
From
would be nice if we could change the signature ofget_or_create
to accept animpl Into<S>
so you don't have to call.into
.Unfortunately we can't do that without requiring ownership on _every_callsite which would require allocations even though we only need ownership inside the
get_or_create
function for the first call. Meaning a lot of these allocations would be wasted.I'd be in favor of not obfuscating what we are converting here:
.into
makes it hard to find all usages ofLabels
. Currently, I have to delete theFrom
impl and see where the compiler fails.much clearer to read than this:
The former I can glance over whereas with the latter, my brain stops and is like: "Hang on,
into()
what?". And I have to recall the function signature ofget_or_create
, check the type oflisten_addr
and search forFrom
implementations to understand what is happening here.From
would need to be using a tuple at which point we need a constructor anyway.From
), if we don't use them. Traits are only useful in generic code, so unless we can make a function that usesT: Into
where we can pass a&Multiaddr
, I think this doesn't qualify.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 still need to cut a new release of
multiaddr
. Sorry for the delay.