Skip to content

Commit ded05da

Browse files
committed
improve action to string and unwrap_or_else pattern
1 parent 5b6fd63 commit ded05da

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/github_issue.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use octocrab::params::State;
99

1010
// allowed operations for github issue interactions
1111
#[non_exhaustive]
12-
#[derive(Copy, Clone)]
12+
#[derive(Copy, Clone, Debug)]
1313
pub(super) enum Action {
1414
Create,
1515
List,
@@ -18,15 +18,8 @@ pub(super) enum Action {
1818
}
1919

2020
impl From<Action> for String {
21-
#[allow(unreachable_patterns)]
2221
fn from(action: Action) -> Self {
23-
match action {
24-
Action::Create => String::from("Create"),
25-
Action::List => String::from("List"),
26-
Action::Read => String::from("Read"),
27-
Action::Update => String::from("Update"),
28-
_ => String::from("Unknown"),
29-
}
22+
format!("{action:?}")
3023
}
3124
}
3225

@@ -121,7 +114,7 @@ impl<'issue> Issue<'issue> {
121114
Some(pat) => octocrab::Octocrab::builder()
122115
.personal_token(pat.to_string())
123116
.build()
124-
.unwrap_or({
117+
.unwrap_or_else(|_| {
125118
log::warn!("could not authenticate client with Personal Access Token");
126119
log::warn!("will continue with unauthenticated client");
127120
octocrab::Octocrab::default()

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl concourse_resource::Resource for GithubIssue {
3333

3434
if source.owner().is_empty() || source.repo().is_empty() {
3535
panic!(
36-
"both 'owner' and 'repo' are required parameters for the Github Issue Resource 'source'"
36+
"both 'owner' and 'repo' are required parameters for the Github Issue resource 'source'"
3737
);
3838
}
3939

0 commit comments

Comments
 (0)