Skip to content
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

Merged
merged 8 commits into from
Dec 23, 2024
Merged

✨ alert trait #88

merged 8 commits into from
Dec 23, 2024

Conversation

comavius
Copy link
Member

@comavius comavius commented Dec 23, 2024

関連Issue

概要

alertを出すときに使うtrait

変更内容

  • Alert traitを追加

チェックリスト

  • テストが通っている
  • 下記のいずれかを満たしている
      • 変更点についてテストを追加/修正した
      • テストを追加するissueを立てた
      • テストが不要な変更である
  • レビュワーを指定した
  • タグをつけた

補足

@comavius comavius added the enhancement New feature or request label Dec 23, 2024
@comavius comavius self-assigned this Dec 23, 2024
Copy link
Collaborator

@kenken714 kenken714 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async traitにしてください

Copy link
Collaborator

@kenken714 kenken714 left a 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 があると嬉しい

@kenken714
Copy link
Collaborator

send_alert の引数で、Option に kind があると嬉しい

うそ

@kenken714
Copy link
Collaborator

enumに対して Display を実装すればよい
ex:

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);
    }
}

@comavius comavius requested a review from kenken714 December 23, 2024 07:53
Copy link
Collaborator

@kenken714 kenken714 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGRM

@comavius comavius requested a review from kenken714 December 23, 2024 07:56
Copy link
Collaborator

@kenken714 kenken714 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm2

@comavius comavius merged commit 2f6ba98 into develop Dec 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alert traitを作る
2 participants