diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6598808..cb902b9 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,12 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. +== {compare-url}/v0.7.7\...HEAD[Unreleased] + +=== Fixed + +* Fix clippy warnings for examples ({pull-request-url}/70[#70]) + == {compare-url}/v0.7.6\...v0.7.7[0.7.7] - 2023-12-07 === Changed diff --git a/examples/cat.rs b/examples/cat.rs index 6c81525..c5a9df5 100644 --- a/examples/cat.rs +++ b/examples/cat.rs @@ -13,12 +13,13 @@ // Lint levels of Clippy. #![warn(clippy::cargo, clippy::nursery, clippy::pedantic)] -#[cfg(feature = "std")] -use std::io::Read; - #[cfg(feature = "std")] fn main() -> std::process::ExitCode { - use std::{env, fs, io, process::ExitCode}; + use std::{ + env, fs, + io::{self, Read}, + process::ExitCode, + }; let args: Vec<_> = env::args_os().skip(1).collect(); @@ -34,8 +35,7 @@ fn main() -> std::process::ExitCode { Ok(strings) => strings, Err(err) => { eprintln!("Error: {err}"); - return sysexits::ExitCode::try_from(err.kind()) - .map_or(ExitCode::FAILURE, ExitCode::from); + return sysexits::ExitCode::from(err).into(); } }; diff --git a/examples/cmp.rs b/examples/cmp.rs index 1f6f57e..64b3f71 100644 --- a/examples/cmp.rs +++ b/examples/cmp.rs @@ -11,9 +11,6 @@ // Lint levels of Clippy. #![warn(clippy::cargo, clippy::nursery, clippy::pedantic)] -#[cfg(feature = "std")] -use std::process::Termination; - #[cfg(feature = "std")] enum ExitCode { Same, @@ -30,7 +27,7 @@ impl From for ExitCode { } #[cfg(feature = "std")] -impl Termination for ExitCode { +impl std::process::Termination for ExitCode { fn report(self) -> std::process::ExitCode { use std::process::ExitCode; @@ -49,7 +46,7 @@ fn main() -> ExitCode { let args: Vec<_> = env::args_os().skip(1).take(2).collect(); - let files = if let (Some(from), Some(to)) = (args.get(0), args.get(1)) { + let files = if let (Some(from), Some(to)) = (args.first(), args.get(1)) { (PathBuf::from(from), PathBuf::from(to)) } else { eprintln!("Error: files are missing"); @@ -60,8 +57,7 @@ fn main() -> ExitCode { Ok(bytes) => bytes, Err(err) => { eprintln!("Error: {err}"); - return sysexits::ExitCode::try_from(err.kind()) - .map_or(ExitCode::Trouble, ExitCode::from); + return sysexits::ExitCode::from(err).into(); } }; diff --git a/examples/isutf8.rs b/examples/isutf8.rs index a4e0415..11bce5d 100644 --- a/examples/isutf8.rs +++ b/examples/isutf8.rs @@ -12,12 +12,13 @@ // Lint levels of Clippy. #![warn(clippy::cargo, clippy::nursery, clippy::pedantic)] -#[cfg(feature = "std")] -use std::io::Read; - #[cfg(feature = "std")] fn main() -> sysexits::ExitCode { - use std::{env, fs, io, str}; + use std::{ + env, fs, + io::{self, Read}, + str, + }; use sysexits::ExitCode;