-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from nikomatsakis/main
link tracking issues
- Loading branch information
Showing
35 changed files
with
427 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::fmt::Display; | ||
|
||
use crate::re::TRACKING_ISSUE; | ||
|
||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)] | ||
pub struct IssueId { | ||
/// Something like `rust-lang/rust-project-goals` | ||
pub repository: String, | ||
|
||
/// Something like `22` | ||
pub number: u64, | ||
} | ||
|
||
impl IssueId { | ||
pub fn new(repository: &(impl Display + ?Sized), number: u64) -> Self { | ||
Self { | ||
repository: repository.to_string(), | ||
number, | ||
} | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for IssueId { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{self}") | ||
} | ||
} | ||
|
||
impl std::fmt::Display for IssueId { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!( | ||
f, | ||
"[{repository}#{number}]", | ||
repository = self.repository, | ||
number = self.number, | ||
) | ||
} | ||
} | ||
|
||
impl std::str::FromStr for IssueId { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
let Some(c) = TRACKING_ISSUE.captures(s) else { | ||
anyhow::bail!("invalid issue-id") | ||
}; | ||
|
||
Ok(IssueId::new(&c[1], c[2].parse()?)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub(super) fn generate_json() { | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.