Skip to content

Commit fccc094

Browse files
committed
Make minor improvements and cleanups
1 parent 0c6fd4d commit fccc094

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

xtask/src/publish.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ impl flags::PublishReleaseNotes {
1616
format!("\nSee also [original changelog]({original_changelog_url}).");
1717
markdown.push_str(&additional_paragraph);
1818
if self.dry_run {
19-
println!("{}", markdown);
19+
println!("{markdown}");
2020
} else {
21-
update_release(sh, &tag_name, &markdown)?;
21+
update_release(sh, tag_name, &markdown)?;
2222
}
2323
Ok(())
2424
}
@@ -67,7 +67,7 @@ fn update_release(sh: &Shell, tag_name: &str, release_notes: &str) -> Result<()>
6767
Err(_) => bail!("Please obtain a personal access token from https://github.com/settings/tokens and set the `GITHUB_TOKEN` environment variable."),
6868
};
6969
let accept = "Accept: application/vnd.github+json";
70-
let authorization = format!("Authorization: Bearer {}", token);
70+
let authorization = format!("Authorization: Bearer {token}");
7171
let api_version = "X-GitHub-Api-Version: 2022-11-28";
7272
let release_url = "https://api.github.com/repos/rust-lang/rust-analyzer/releases";
7373

@@ -80,10 +80,10 @@ fn update_release(sh: &Shell, tag_name: &str, release_notes: &str) -> Result<()>
8080

8181
let mut patch = String::new();
8282
write_json::object(&mut patch)
83-
.string("tag_name", &tag_name)
83+
.string("tag_name", tag_name)
8484
.string("target_commitish", "master")
85-
.string("name", &tag_name)
86-
.string("body", &release_notes)
85+
.string("name", tag_name)
86+
.string("body", release_notes)
8787
.bool("draft", false)
8888
.bool("prerelease", false);
8989
let _ = cmd!(
@@ -102,7 +102,7 @@ mod tests {
102102
#[test]
103103
fn original_changelog_url_creation() {
104104
let input = "2019-07-24-changelog-0.adoc";
105-
let actual = create_original_changelog_url(&input);
105+
let actual = create_original_changelog_url(input);
106106
let expected = "https://rust-analyzer.github.io/thisweek/2019/07/24/changelog-0.html";
107107
assert_eq!(actual, expected);
108108
}

xtask/src/publish/notes.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use std::{
55
iter::Peekable,
66
};
77

8-
const LISTING_DELIMITER: &'static str = "----";
9-
const IMAGE_BLOCK_PREFIX: &'static str = "image::";
10-
const VIDEO_BLOCK_PREFIX: &'static str = "video::";
8+
const LISTING_DELIMITER: &str = "----";
9+
const IMAGE_BLOCK_PREFIX: &str = "image::";
10+
const VIDEO_BLOCK_PREFIX: &str = "video::";
1111

1212
struct Converter<'a, 'b, R: BufRead> {
1313
iter: &'a mut Peekable<Lines<R>>,
@@ -89,7 +89,7 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
8989
while let Some(line) = self.iter.peek() {
9090
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
9191

92-
if get_list_item(&line).is_some() {
92+
if get_list_item(line).is_some() {
9393
let line = self.iter.next().unwrap()?;
9494
let line = process_inline_macros(&line)?;
9595
let (marker, item) = get_list_item(&line).unwrap();
@@ -253,17 +253,16 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
253253
{
254254
while let Some(line) = self.iter.peek() {
255255
let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
256-
if predicate(&line) {
256+
if predicate(line) {
257257
break;
258258
}
259259

260260
self.write_indent(level);
261261
let line = self.iter.next().unwrap()?;
262262
let line = line.trim_start();
263-
let line = process_inline_macros(&line)?;
264-
if line.ends_with('+') {
265-
let line = &line[..(line.len() - 1)];
266-
self.output.push_str(line);
263+
let line = process_inline_macros(line)?;
264+
if let Some(stripped) = line.strip_suffix('+') {
265+
self.output.push_str(stripped);
267266
self.output.push('\\');
268267
} else {
269268
self.output.push_str(&line);
@@ -339,8 +338,8 @@ fn get_title(line: &str) -> Option<(usize, &str)> {
339338
}
340339

341340
fn get_list_item(line: &str) -> Option<(ListMarker, &str)> {
342-
const HYPHYEN_MARKER: &'static str = "- ";
343-
if let Some(text) = line.strip_prefix(HYPHYEN_MARKER) {
341+
const HYPHEN_MARKER: &str = "- ";
342+
if let Some(text) = line.strip_prefix(HYPHEN_MARKER) {
344343
Some((ListMarker::Hyphen, text))
345344
} else if let Some((count, text)) = strip_prefix_symbol(line, '*') {
346345
Some((ListMarker::Asterisk(count), text))

0 commit comments

Comments
 (0)