Skip to content

Commit e04367f

Browse files
committed
cargo fmt
1 parent 2b29cf5 commit e04367f

File tree

8 files changed

+76
-51
lines changed

8 files changed

+76
-51
lines changed

crates/mdbook-goals/src/mdbook_preprocessor.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,19 @@ impl<'c> GoalPreprocessorWithContext<'c> {
270270
return Ok(());
271271
}
272272
let config = Configuration::get();
273-
let rows = std::iter::once(vec!["Ask".to_string(), "aka".to_string(), "Description".to_string()])
274-
.chain(config.team_asks.iter().map(|(name, details)| {
275-
vec![
276-
format!("{name:?}"),
277-
details.short.to_string(),
278-
details.about.to_string(),
279-
]
280-
}))
281-
.collect::<Vec<Vec<String>>>();
273+
let rows = std::iter::once(vec![
274+
"Ask".to_string(),
275+
"aka".to_string(),
276+
"Description".to_string(),
277+
])
278+
.chain(config.team_asks.iter().map(|(name, details)| {
279+
vec![
280+
format!("{name:?}"),
281+
details.short.to_string(),
282+
details.about.to_string(),
283+
]
284+
}))
285+
.collect::<Vec<Vec<String>>>();
282286
let table = util::format_table(&rows);
283287
let new_content = re::VALID_TEAM_ASKS.replace_all(&chapter.content, table);
284288
chapter.content = new_content.to_string();

crates/rust-project-goals-cli-llm/src/updates.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ fn help_wanted(
169169

170170
let mut help_wanted = vec![];
171171

172-
let tldr_has_help_wanted = tldr.as_deref().unwrap_or("").lines().any(|line| HELP_WANTED.is_match(line));
172+
let tldr_has_help_wanted = tldr
173+
.as_deref()
174+
.unwrap_or("")
175+
.lines()
176+
.any(|line| HELP_WANTED.is_match(line));
173177

174178
for comment in comments {
175179
let mut lines = comment.body.split('\n').peekable();
@@ -180,8 +184,8 @@ fn help_wanted(
180184
while let Some(line) = lines.next() {
181185
if let Some(c) = HELP_WANTED.captures(line) {
182186
help_wanted.push(HelpWanted {
183-
text: c["text"].to_string()
184-
});
187+
text: c["text"].to_string(),
188+
});
185189
break;
186190
}
187191
}
@@ -200,10 +204,7 @@ fn help_wanted(
200204
Ok((tldr_has_help_wanted || !help_wanted.is_empty(), help_wanted))
201205
}
202206

203-
fn why_this_goal(
204-
issue_id: &IssueId,
205-
issue: &ExistingGithubIssue,
206-
) -> anyhow::Result<String> {
207+
fn why_this_goal(issue_id: &IssueId, issue: &ExistingGithubIssue) -> anyhow::Result<String> {
207208
let sections = markwaydown::parse_text(issue_id.url(), &issue.body)?;
208209
for section in sections {
209210
if section.title == "Why this goal?" {

crates/rust-project-goals-cli/src/rfc.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use rust_project_goals::{
1313
gh::{
1414
issue_id::{IssueId, Repository},
1515
issues::{
16-
change_milestone, change_title, create_comment, create_issue, fetch_issue, list_issues_in_milestone, lock_issue, sync_assignees, update_issue_body, CONTINUING_GOAL_PREFIX, FLAGSHIP_LABEL, LOCK_TEXT
16+
change_milestone, change_title, create_comment, create_issue, fetch_issue,
17+
list_issues_in_milestone, lock_issue, sync_assignees, update_issue_body,
18+
CONTINUING_GOAL_PREFIX, FLAGSHIP_LABEL, LOCK_TEXT,
1719
},
1820
labels::GhLabel,
1921
},
@@ -175,7 +177,6 @@ pub fn generate_issues(
175177
eprintln!("Use `--commit` to execute the actions.");
176178
return Ok(());
177179
}
178-
179180
}
180181
}
181182

@@ -301,7 +302,10 @@ fn initialize_issues<'doc>(
301302
let existing_issue = if let Some(tracking_issue) = desired_issue.tracking_issue {
302303
// a. We first check if there is a declared tracking issue in the markdown file.
303304
// If so, check if we've already loaded its data.
304-
if let Some(issue) = milestone_issues.iter().find(|issue| issue.number == tracking_issue.number) {
305+
if let Some(issue) = milestone_issues
306+
.iter()
307+
.find(|issue| issue.number == tracking_issue.number)
308+
{
305309
// If so, reuse it to avoid latency.
306310
Some(issue.clone())
307311
} else {
@@ -318,7 +322,10 @@ fn initialize_issues<'doc>(
318322
// is created, we first create an issue for it, then do a loop and execute again.
319323
// This second time, we will find the issue with the known title, get its
320324
// number, and put that number into the markdown.
321-
milestone_issues.iter().find(|issue| issue.title == desired_issue.title).cloned()
325+
milestone_issues
326+
.iter()
327+
.find(|issue| issue.title == desired_issue.title)
328+
.cloned()
322329
};
323330

324331
match existing_issue {
@@ -338,9 +345,12 @@ fn initialize_issues<'doc>(
338345
.collect(),
339346
});
340347
}
341-
348+
342349
if existing_issue.title != desired_issue.title {
343-
actions.insert(GithubAction::ChangeTitle { number: existing_issue.number, title: desired_issue.title });
350+
actions.insert(GithubAction::ChangeTitle {
351+
number: existing_issue.number,
352+
title: desired_issue.title,
353+
});
344354
}
345355

346356
if existing_issue.milestone.as_ref().map(|m| m.title.as_str()) != Some(timeframe) {
@@ -350,9 +360,7 @@ fn initialize_issues<'doc>(
350360
});
351361
actions.insert(GithubAction::Comment {
352362
number: existing_issue.number,
353-
body: format!(
354-
"{CONTINUING_GOAL_PREFIX} {timeframe}",
355-
),
363+
body: format!("{CONTINUING_GOAL_PREFIX} {timeframe}",),
356364
});
357365
}
358366

@@ -610,7 +618,7 @@ impl GithubAction<'_> {
610618
change_title(repository, number, &title)?;
611619
Ok(())
612620
}
613-
621+
614622
GithubAction::Comment { number, body } => {
615623
create_comment(repository, number, &body)?;
616624
Ok(())

crates/rust-project-goals/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ impl Configuration {
3131
fn load() -> anyhow::Result<Configuration> {
3232
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
3333
let toml_file = manifest_dir.join("../../rust-project-goals.toml");
34-
let toml_string = std::fs::read_to_string(&toml_file).with_context(|| format!("loading configuration from {}", toml_file.display()))?;
34+
let toml_string = std::fs::read_to_string(&toml_file)
35+
.with_context(|| format!("loading configuration from {}", toml_file.display()))?;
3536
Ok(toml::from_str(&toml_string)?)
3637
}
3738
}

crates/rust-project-goals/src/format_team_ask.rs

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
use std::{collections::{BTreeMap, BTreeSet}, path::PathBuf};
2-
3-
use crate::{config::Configuration, goal::TeamAsk, team::TeamName, util::{self, ARROW}};
1+
use std::{
2+
collections::{BTreeMap, BTreeSet},
3+
path::PathBuf,
4+
};
5+
6+
use crate::{
7+
config::Configuration,
8+
goal::TeamAsk,
9+
team::TeamName,
10+
util::{self, ARROW},
11+
};
412

513
/// Format a set of team asks into a table, with asks separated by team and grouped by kind.
614
///
@@ -83,7 +91,10 @@ pub fn format_team_asks(asks_of_any_team: &[&TeamAsk]) -> anyhow::Result<String>
8391
let mut maybe_footnote = |text: &str| -> String {
8492
if text.len() > FOOTNOTE_LEN {
8593
let footnote_index = footnotes.len() + 1;
86-
footnotes.push(format!("\\*{footnote_index}: {text} ([from here]({link}))", link = ask.link_path.display()));
94+
footnotes.push(format!(
95+
"\\*{footnote_index}: {text} ([from here]({link}))",
96+
link = ask.link_path.display()
97+
));
8798
format!("\\*{footnote_index}")
8899
} else {
89100
text.to_string()
@@ -107,14 +118,12 @@ pub fn format_team_asks(asks_of_any_team: &[&TeamAsk]) -> anyhow::Result<String>
107118
// Create the table itself.
108119
let table = {
109120
let headings = std::iter::once("Goal".to_string())
110-
.chain(
111-
ask_headings
112-
.iter()
113-
.map(|&ask_kind| format!(
114-
"[{team_ask_short}][valid_team_asks]", // HACK: This should not be hardcoded in the code.
115-
team_ask_short = config.team_asks[ask_kind].short,
116-
))
117-
) // e.g. "discussion and moral support"
121+
.chain(ask_headings.iter().map(|&ask_kind| {
122+
format!(
123+
"[{team_ask_short}][valid_team_asks]", // HACK: This should not be hardcoded in the code.
124+
team_ask_short = config.team_asks[ask_kind].short,
125+
)
126+
})) // e.g. "discussion and moral support"
118127
.collect::<Vec<String>>();
119128

120129
let rows = goal_rows.into_iter().map(|(goal_data, goal_columns)| {
@@ -146,10 +155,16 @@ struct GoalData<'g> {
146155
impl<'g> GoalData<'g> {
147156
fn new(ask: &'g TeamAsk) -> anyhow::Result<Self> {
148157
match &ask.goal_titles[..] {
149-
[goal_title] => Ok(Self { goal_title, subgoal_title: None, link: &ask.link_path }),
150-
[goal_title, subgoal_title] => {
151-
Ok(Self { goal_title, subgoal_title: Some(subgoal_title), link: &ask.link_path })
152-
}
158+
[goal_title] => Ok(Self {
159+
goal_title,
160+
subgoal_title: None,
161+
link: &ask.link_path,
162+
}),
163+
[goal_title, subgoal_title] => Ok(Self {
164+
goal_title,
165+
subgoal_title: Some(subgoal_title),
166+
link: &ask.link_path,
167+
}),
153168
_ => anyhow::bail!(
154169
"expected either 1 or 2 goal titles, not {:?}",
155170
ask.goal_titles

crates/rust-project-goals/src/gh/issues.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ pub fn create_issue(
197197
}
198198
}
199199

200-
pub fn change_title(
201-
repository: &Repository,
202-
number: u64,
203-
title: &str,
204-
) -> anyhow::Result<()> {
200+
pub fn change_title(repository: &Repository, number: u64, title: &str) -> anyhow::Result<()> {
205201
let mut command = Command::new("gh");
206202
command
207203
.arg("-R")

crates/rust-project-goals/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
pub mod config;
2+
pub mod format_team_ask;
13
pub mod gh;
24
pub mod goal;
35
pub mod markwaydown;
46
pub mod re;
57
pub mod team;
68
pub mod util;
7-
pub mod config;
8-
pub mod format_team_ask;

crates/rust-project-goals/src/team.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl TeamName {
8888
/// Name in braces (markdown link), like `"[compiler][]"`
8989
pub fn name(&self) -> String {
9090
format!("[{}][]", self.0)
91-
}
91+
}
9292

9393
/// Name and link, like `"[compiler](https://...)"`
9494
pub fn name_and_link(&self) -> String {

0 commit comments

Comments
 (0)