Skip to content

Commit 9a776e9

Browse files
feat: add get method to Jobs struct for retrieving jobs by key (#134)
Co-authored-by: amitksingh1490 <amitksingh1490@users.noreply.github.com>
1 parent 7e2d805 commit 9a776e9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/target/
22
/**/target/
3+
.forge.*
4+
.env

crates/gh-workflow/src/workflow.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ impl Jobs {
2020
pub fn insert(&mut self, key: String, value: Job) {
2121
self.0.insert(key, value);
2222
}
23+
24+
/// Gets a reference to a job by its key.
25+
///
26+
/// # Arguments
27+
///
28+
/// * `key` - The key of the job to retrieve
29+
///
30+
/// # Returns
31+
///
32+
/// Returns `Some(&Job)` if the job exists, `None` otherwise.
33+
pub fn get(&self, key: &str) -> Option<&Job> {
34+
self.0.get(key)
35+
}
2336
}
2437

2538
/// Represents the configuration for a GitHub workflow.

0 commit comments

Comments
 (0)