-
Notifications
You must be signed in to change notification settings - Fork 80
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
feat(registry): add sub_registry_with_labels
#145
feat(registry): add sub_registry_with_labels
#145
Conversation
89f8c3c
to
c0cfad7
Compare
68a67fd
to
d42bf63
Compare
@mxinden any update/feedback on this? |
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.
Change looks good to me. Thanks. Though now that we have sub_registry_with_labelS
we can simply sub_registry_with_label
, right? What do you think?
modified src/registry.rs
@@ -239,11 +239,20 @@ impl Registry {
&mut self,
label: (Cow<'static, str>, Cow<'static, str>),
) -> &mut Self {
- let mut labels = self.labels.clone();
- labels.push(label);
+ self.sub_registry_with_labels(std::iter::once(label))
+ }
+
+ /// Like [`Registry::sub_registry_with_prefix`] but with multiple labels instead.
+ pub fn sub_registry_with_labels(
+ &mut self,
+ labels: impl Iterator<Item = (Cow<'static, str>, Cow<'static, str>)>,
+ ) -> &mut Self {
+ let mut new_labels = self.labels.clone();
+ new_labels.extend(labels);
+
let sub_registry = Registry {
prefix: self.prefix.clone(),
- labels,
+ labels: new_labels,
..Default::default()
};
d42bf63
to
dd0acd3
Compare
Thanks for the suggestion! I updated the code. |
26f83c6
to
23f651d
Compare
Signed-off-by: Adrian Pop <popadrian1996@gmail.com>
23f651d
to
03bbfbb
Compare
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.
Thanks for the follow-ups.
sub_registry_with_labels
sub_registry_with_labels
method per discussion in Allow multiple labels in sub_registry_with_label method #144