-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: Enhanced parser / redmine error-handling #152
Conversation
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.
あとで改善したいところ
if message.embeds.first().is_none() { | ||
return; | ||
}; | ||
let embed = match parse_embed(message.embeds.first().unwrap()) { |
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.
if message.embeds.first().is_none() { | |
return; | |
}; | |
let embed = match parse_embed(message.embeds.first().unwrap()) { | |
let Some(first_embed) = message.embeds.first else { return; }; | |
let embed = match parse_embed(first_embed) { |
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.
let Some(...)
そんな記法あったの
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.
let-else
でググると良い
} | ||
|
||
fn parse_issue_number(title: &String) -> anyhow::Result<u16, ParseEnvIDsError> { | ||
let re = match regex::Regex::new(r"#(\d+)") { |
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.
毎回Regexの構築が走って無駄なので https://doc.rust-lang.org/std/cell/struct.LazyCell.html で持ちたい
Some(caps) => match caps.get(1).unwrap().as_str().parse::<u16>() { | ||
Ok(num) => Ok(num), | ||
Err(why) => Err(ParseEnvIDsError::FailedToParseIssueNumber(why.to_string())), | ||
}, |
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.
panic-safeにするなら気持ち的にはget(1).unwrap()
をやめたくない?という気持ちがある。
そうではなくてもunwrap
ではなくexpect
にしたいところ
SSIA