team.rs 877 B

12345678910111213141516171819202122232425262728293031323334353637
  1. use failure::Error;
  2. use std::str::FromStr;
  3. #[derive(Debug, PartialEq, Eq)]
  4. pub enum Team {
  5. Libs,
  6. Compiler,
  7. Lang,
  8. }
  9. impl Team {
  10. pub fn label(&self) -> crate::github::Label {
  11. match self {
  12. Team::Libs => crate::github::Label {
  13. name: String::from("T-libs"),
  14. },
  15. Team::Compiler => crate::github::Label {
  16. name: String::from("T-compiler"),
  17. },
  18. Team::Lang => crate::github::Label {
  19. name: String::from("T-lang"),
  20. },
  21. }
  22. }
  23. }
  24. impl FromStr for Team {
  25. type Err = Error;
  26. fn from_str(s: &str) -> Result<Self, Self::Err> {
  27. Ok(match s {
  28. "libs" => Team::Libs,
  29. "compiler" => Team::Compiler,
  30. "lang" => Team::Lang,
  31. _ => failure::bail!("unknown team: {:?}", s),
  32. })
  33. }
  34. }