Skip to content

Commit d7a6cb4

Browse files
Implement contains for a few list types
1 parent dc56241 commit d7a6cb4

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## v0.50.0 (in development)
44

5-
No changes yet.
5+
### Enhancements
6+
7+
* `responses::TagList`, `responses::PluginList`, `responses::NodeList`, `responses::FeatureFlagList`, `responses::DeprecatedFeatureList`
8+
now implement `contains`.
69

710

811
## v0.49.0 (Sep 07, 2025)

src/responses.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ impl TagList {
5252
pub fn is_empty(&self) -> bool {
5353
self.0.is_empty()
5454
}
55+
56+
pub fn contains(&self, key: &str) -> bool {
57+
self.0.iter().any(|s| s == key)
58+
}
5559
}
5660

5761
impl IntoIterator for TagList {
@@ -74,6 +78,10 @@ impl PluginList {
7478
pub fn is_empty(&self) -> bool {
7579
self.0.is_empty()
7680
}
81+
82+
pub fn contains(&self, key: &str) -> bool {
83+
self.0.iter().any(|s| s == key)
84+
}
7785
}
7886

7987
impl IntoIterator for PluginList {
@@ -225,6 +233,10 @@ impl NodeList {
225233
pub fn is_empty(&self) -> bool {
226234
self.len() == 0
227235
}
236+
237+
pub fn contains(&self, key: &str) -> bool {
238+
self.0.iter().any(|s| s == key)
239+
}
228240
}
229241

230242
impl IntoIterator for NodeList {
@@ -2297,6 +2309,10 @@ impl FeatureFlagList {
22972309
pub fn is_empty(&self) -> bool {
22982310
self.len() == 0
22992311
}
2312+
2313+
pub fn contains(&self, key: &str) -> bool {
2314+
self.0.iter().any(|ff| ff.name == key)
2315+
}
23002316
}
23012317

23022318
impl IntoIterator for FeatureFlagList {
@@ -2394,6 +2410,10 @@ impl DeprecatedFeatureList {
23942410
pub fn is_empty(&self) -> bool {
23952411
self.0.is_empty()
23962412
}
2413+
2414+
pub fn contains(&self, key: &str) -> bool {
2415+
self.0.iter().any(|df| df.name == key)
2416+
}
23972417
}
23982418

23992419
impl IntoIterator for DeprecatedFeatureList {

0 commit comments

Comments
 (0)