-
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
✨ alert trait #88
✨ alert trait #88
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.
async traitにしてください
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.
send_alert の引数で、Option に kind があると嬉しい
うそ |
enumに対して Display を実装すればよい enum AlertKind {
Error(String),
Note(String),
}
impl fmt::Display for AlertKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
AlertKind::Error(ref s) => write!(f, "Error: {}", s),
AlertKind::Note(ref s) => write!(f, "Note: {}", s),
}
}
}
pub trait Alert {
fn send_alert<T: std::fmt::Display>(&self, message: T);
}
impl Alert for AlertKind {
fn send_alert<T: std::fmt::Display>(&self, message: T) {
println!("{}", message);
}
} |
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.
LGRM
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.
lgtm2
関連Issue
概要
alertを出すときに使うtrait
変更内容
チェックリスト
補足