From 5f837f4dd6a41c6bf41a0e49e27d8997d2a7e6f8 Mon Sep 17 00:00:00 2001 From: Niklas Mohrin Date: Tue, 18 Aug 2026 15:50:17 +0200 Subject: [PATCH] Bump edition to 2024 (#510) --- Cargo.toml | 2 +- src/cache.rs | 8 ++++---- src/cli.rs | 2 +- src/config.rs | 16 ++++++++++------ src/main.rs | 8 +++++--- src/output.rs | 2 +- tests/lib.rs | 2 +- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 57a560e..2282217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.tealdeer.org" version = "1.8.1" include = ["/src/**/*", "/tests/**/*", "/Cargo.toml", "/README.md", "/LICENSE-*", "/screenshot.png", "completion/*"] rust-version = "1.87" # MSRV -edition = "2021" +edition = "2024" [[bin]] name = "tldr" diff --git a/src/cache.rs b/src/cache.rs index afa3603..8d5b970 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -5,12 +5,12 @@ use std::{ time::{Duration, SystemTime}, }; -use anyhow::{anyhow, bail, ensure, Context, Result}; +use anyhow::{Context, Result, anyhow, bail, ensure}; use log::{debug, info}; use ureq::{ + Agent, http::StatusCode, tls::{RootCerts, TlsConfig, TlsProvider}, - Agent, }; use zip::ZipArchive; @@ -128,7 +128,7 @@ impl<'a> Cache<'a> { None } - pub fn list_pages(&self) -> Result> { + pub fn list_pages(&self) -> Result + use<>> { let mut pages = Vec::new(); let mut append_all = |directory: &Path, suffix: &str| -> Result<()> { @@ -215,7 +215,7 @@ impl<'a> Cache<'a> { &mut self, archive_url: &str, tls_backend: TlsBackend, - ) -> Result>> { + ) -> Result> + use<'_>> { let client = Self::build_client(tls_backend); // Download everything before deleting anything diff --git a/src/cli.rs b/src/cli.rs index 5dc58f5..b477a3f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; -use clap::{builder::ArgAction, ArgGroup, Parser}; +use clap::{ArgGroup, Parser, builder::ArgAction}; use crate::types::{ColorOptions, PlatformType}; diff --git a/src/config.rs b/src/config.rs index 84b1dac..805ed52 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,7 +9,7 @@ use std::{ time::Duration, }; -use anyhow::{anyhow, bail, ensure, Context, Result}; +use anyhow::{Context, Result, anyhow, bail, ensure}; use clap::ValueEnum; use log::info; use serde::Serialize as _; @@ -42,7 +42,7 @@ struct SystemDirectories { impl SystemDirectories { fn discover() -> Result { use etcetera::{ - app_strategy::choose_native_strategy, choose_app_strategy, AppStrategy, AppStrategyArgs, + AppStrategy, AppStrategyArgs, app_strategy::choose_native_strategy, choose_app_strategy, }; let args = AppStrategyArgs { @@ -579,7 +579,7 @@ impl TryFrom for TlsBackend { "Unsupported TLS backend: {}. This tealdeer build has support for the following options: {}", raw, supported_tls_backends_string(), - )) + )), } } } @@ -654,7 +654,9 @@ impl<'a> Config<'a> { // For backwards compatibility reasons, the cache directory can be // overridden using an env variable. This is deprecated and will be // phased out in the future. - eprintln!("Warning: The ${cache_dir_env_var} env variable is deprecated, use the `cache_dir` option in the config file instead."); + eprintln!( + "Warning: The ${cache_dir_env_var} env variable is deprecated, use the `cache_dir` option in the config file instead." + ); PathWithSource { path: PathBuf::from(env_var), source: PathSource::EnvVar, @@ -766,7 +768,7 @@ impl ConfigLoader { return Err(e).context(format!( "Could not read config file contents from {}.", path.path().display() - )) + )); } }; @@ -794,7 +796,9 @@ impl ConfigLoader { let mut entry = &mut config_table; for subkey in name.split('.') { let toml::Value::Table(entry_table) = entry else { - bail!("\"{name}\" is not a valid identifier since \"{subkey}\" already refers to a value which is not a toml-Table."); + bail!( + "\"{name}\" is not a valid identifier since \"{subkey}\" already refers to a value which is not a toml-Table." + ); }; entry = entry_table diff --git a/src/main.rs b/src/main.rs index 52515b5..5044bd2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ use std::{ process::{Command, ExitCode}, }; -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result, anyhow}; use cache::{CacheConfig, TLDR_OLD_PAGES_DIR}; use clap::Parser; use config::{ConfigLoader, Language, StyleConfig, TlsBackend}; @@ -56,7 +56,7 @@ use crate::{ cache::{Cache, PageLookupResult, TLDR_PAGES_DIR}, cli::Cli, config::{ - get_config_dir, make_default_config, supported_tls_backends_string, Config, PathWithSource, + Config, PathWithSource, get_config_dir, make_default_config, supported_tls_backends_string, }, output::print_page, types::ColorOptions, @@ -324,7 +324,9 @@ fn try_main(args: Cli, enable_styles: bool) -> Result { print_error(enable_styles, &e); eprintln!(); - eprintln!("Note: Update errors are often caused by unexpected or missing TLS certificates."); + eprintln!( + "Note: Update errors are often caused by unexpected or missing TLS certificates." + ); eprintln!( "You are currently using the following TLS backend: {}", config.updates.tls_backend, diff --git a/src/output.rs b/src/output.rs index a38378f..498a8d4 100644 --- a/src/output.rs +++ b/src/output.rs @@ -7,7 +7,7 @@ use yansi::Paint; use crate::{ config::{Config, StyleConfig}, - formatter::{highlight_lines, PageSnippet}, + formatter::{PageSnippet, highlight_lines}, line_iterator::LineIterator, }; diff --git a/tests/lib.rs b/tests/lib.rs index c6df992..e5050bc 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,7 +1,7 @@ //! Integration tests. use std::{ - fs::{self, create_dir_all, File}, + fs::{self, File, create_dir_all}, io::{self, Write}, path::{Path, PathBuf}, process::Command,