From 4f94a87681d4ddd3d55cc22057da0055be161eba Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Thu, 27 Feb 2025 15:03:50 +0000 Subject: [PATCH] cargo fmt --- dprint.json | 2 +- mdbook-course/src/course.rs | 14 ++++++-------- mdbook-exerciser/src/lib.rs | 2 +- mdbook-exerciser/src/main.rs | 2 +- .../async-exercises/chat-async/src/bin/client.rs | 2 +- .../async-exercises/chat-async/src/bin/server.rs | 2 +- .../sync-exercises/dining-philosophers.rs | 2 +- src/concurrency/sync-exercises/link-checker.rs | 4 ++-- src/tuples-and-arrays/exercise.rs | 4 ++-- third_party/cxx/blobstore/build.rs | 3 ++- xtask/src/main.rs | 3 ++- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dprint.json b/dprint.json index 244ce753..d47cd41c 100644 --- a/dprint.json +++ b/dprint.json @@ -9,7 +9,7 @@ "command": "yapf3", "exts": ["py"] }, { - "command": "rustup run stable rustfmt --edition 2021", + "command": "rustup run stable rustfmt --edition 2024", "exts": ["rs"] }] }, diff --git a/mdbook-course/src/course.rs b/mdbook-course/src/course.rs index 354b7e24..ec9fa3e7 100644 --- a/mdbook-course/src/course.rs +++ b/mdbook-course/src/course.rs @@ -35,8 +35,8 @@ //! item becomes the first slide in that segment. Any other sub-items of the //! top-level item are treated as further slides in the same segment. -use crate::frontmatter::{split_frontmatter, Frontmatter}; -use crate::markdown::{duration, Table}; +use crate::frontmatter::{Frontmatter, split_frontmatter}; +use crate::markdown::{Table, duration}; use mdbook::book::{Book, BookItem, Chapter}; use std::fmt::Write; use std::path::PathBuf; @@ -318,7 +318,9 @@ impl Session { } format!( "Including {BREAK_DURATION} minute breaks, this session should take about {}. It contains:\n\n{}", - duration(self.minutes()), segments) + duration(self.minutes()), + segments + ) } /// Return the total duration of this session. @@ -337,11 +339,7 @@ impl Session { /// /// This includes breaks between segments. pub fn target_minutes(&self) -> u64 { - if self.target_minutes > 0 { - self.target_minutes - } else { - self.minutes() - } + if self.target_minutes > 0 { self.target_minutes } else { self.minutes() } } } diff --git a/mdbook-exerciser/src/lib.rs b/mdbook-exerciser/src/lib.rs index 8f6040d6..c51bc017 100644 --- a/mdbook-exerciser/src/lib.rs +++ b/mdbook-exerciser/src/lib.rs @@ -14,7 +14,7 @@ use log::{info, trace}; use pulldown_cmark::{Event, Parser, Tag, TagEnd}; -use std::fs::{create_dir_all, File}; +use std::fs::{File, create_dir_all}; use std::io::Write; use std::path::Path; diff --git a/mdbook-exerciser/src/main.rs b/mdbook-exerciser/src/main.rs index 57332ca2..9c2e14e4 100644 --- a/mdbook-exerciser/src/main.rs +++ b/mdbook-exerciser/src/main.rs @@ -14,9 +14,9 @@ use anyhow::Context; use log::trace; +use mdbook::BookItem; use mdbook::book::Book; use mdbook::renderer::RenderContext; -use mdbook::BookItem; use mdbook_exerciser::process; use std::fs::{create_dir, remove_dir_all}; use std::io::stdin; diff --git a/src/concurrency/async-exercises/chat-async/src/bin/client.rs b/src/concurrency/async-exercises/chat-async/src/bin/client.rs index bc912a28..01e0c8fd 100644 --- a/src/concurrency/async-exercises/chat-async/src/bin/client.rs +++ b/src/concurrency/async-exercises/chat-async/src/bin/client.rs @@ -14,8 +14,8 @@ // ANCHOR: solution // ANCHOR: setup -use futures_util::stream::StreamExt; use futures_util::SinkExt; +use futures_util::stream::StreamExt; use http::Uri; use tokio::io::{AsyncBufReadExt, BufReader}; use tokio_websockets::{ClientBuilder, Message}; diff --git a/src/concurrency/async-exercises/chat-async/src/bin/server.rs b/src/concurrency/async-exercises/chat-async/src/bin/server.rs index 46aedbc2..57bc1f7b 100644 --- a/src/concurrency/async-exercises/chat-async/src/bin/server.rs +++ b/src/concurrency/async-exercises/chat-async/src/bin/server.rs @@ -19,7 +19,7 @@ use futures_util::stream::StreamExt; use std::error::Error; use std::net::SocketAddr; use tokio::net::{TcpListener, TcpStream}; -use tokio::sync::broadcast::{channel, Sender}; +use tokio::sync::broadcast::{Sender, channel}; use tokio_websockets::{Message, ServerBuilder, WebSocketStream}; // ANCHOR_END: setup diff --git a/src/concurrency/sync-exercises/dining-philosophers.rs b/src/concurrency/sync-exercises/dining-philosophers.rs index 6900acdb..d6667ecb 100644 --- a/src/concurrency/sync-exercises/dining-philosophers.rs +++ b/src/concurrency/sync-exercises/dining-philosophers.rs @@ -14,7 +14,7 @@ // ANCHOR: solution // ANCHOR: Philosopher -use std::sync::{mpsc, Arc, Mutex}; +use std::sync::{Arc, Mutex, mpsc}; use std::thread; use std::time::Duration; diff --git a/src/concurrency/sync-exercises/link-checker.rs b/src/concurrency/sync-exercises/link-checker.rs index 442add2e..eee665cb 100644 --- a/src/concurrency/sync-exercises/link-checker.rs +++ b/src/concurrency/sync-exercises/link-checker.rs @@ -13,12 +13,12 @@ // limitations under the License. // ANCHOR: solution -use std::sync::{mpsc, Arc, Mutex}; +use std::sync::{Arc, Mutex, mpsc}; use std::thread; // ANCHOR: setup -use reqwest::blocking::Client; use reqwest::Url; +use reqwest::blocking::Client; use scraper::{Html, Selector}; use thiserror::Error; diff --git a/src/tuples-and-arrays/exercise.rs b/src/tuples-and-arrays/exercise.rs index a84caf85..e9c7d665 100644 --- a/src/tuples-and-arrays/exercise.rs +++ b/src/tuples-and-arrays/exercise.rs @@ -40,8 +40,8 @@ fn main() { // ANCHOR_END: main // ANCHOR_END: solution -// This test does not appear in the exercise, as this is very early in the course, but it verifies -// that the solution is correct. +// This test does not appear in the exercise, as this is very early in the +// course, but it verifies that the solution is correct. #[test] fn test_transpose() { let matrix = [ diff --git a/third_party/cxx/blobstore/build.rs b/third_party/cxx/blobstore/build.rs index 41158115..c3b0031e 100644 --- a/third_party/cxx/blobstore/build.rs +++ b/third_party/cxx/blobstore/build.rs @@ -1,6 +1,7 @@ fn main() { // Find target directory, either from CARGO_TARGET_DIR or in-tree if unset. - let mut src_dir = std::env::var_os("CARGO_TARGET_DIR").unwrap_or("../../../target".into()); + let mut src_dir = + std::env::var_os("CARGO_TARGET_DIR").unwrap_or("../../../target".into()); src_dir.push("/cxxbridge/demo/src"); cxx_build::bridge("src/main.rs") diff --git a/xtask/src/main.rs b/xtask/src/main.rs index aacb1ffb..cf818a36 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -21,7 +21,8 @@ use anyhow::{anyhow, Ok, Result}; use clap::Parser; -use std::{env, process::Command}; +use std::env; +use std::process::Command; fn main() -> Result<()> { if let Err(e) = execute_task() {