Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chunkify/src/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl fmt::Display for ChunkStrategyError {
}

/// Marks ChunkStrategyError as a standard error type.
impl std::error::Error for ChunkStrategyError {}
impl error::Error for ChunkStrategyError {}

/// Converts ChunkStrategyError to a byte vector.
///
Expand Down Expand Up @@ -231,7 +231,7 @@ impl<'a> HandleStrategy<'a> for ChunkStrategy<'a> {
for i in *self.get_start_chunk_index()..*self.get_total_chunks() {
let chunk_path: String = self.get_chunk_path(self.get_file_id(), i);
let chunk_data: Vec<u8> = async_read_from_file(&chunk_path).await.map_err(
|error: Box<dyn std::error::Error>| {
|error: Box<dyn error::Error>| {
ChunkStrategyError::ReadChunk(format!(
"Failed to read chunk from {chunk_path}: {error}"
))
Expand Down
2 changes: 1 addition & 1 deletion chunkify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use {r#const::*, r#enum::*, r#struct::*, r#trait::*, r#type::*};
use r#static::*;

use std::{
fmt,
error, fmt,
fs::{self, File, OpenOptions},
hash::BuildHasherDefault,
io::{BufWriter, Error, Write},
Expand Down
4 changes: 2 additions & 2 deletions chunkify/src/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub trait HandleStrategy<'a>: Send + Sync {
///
/// # Returns
///
/// - `impl Future<Output` - Future of the save operation.
/// - `impl Future<Output = ChunkStrategyResult>` - Future of the save operation.
fn save_chunk(
&self,
chunk_data: &'a [u8],
Expand All @@ -29,6 +29,6 @@ pub trait HandleStrategy<'a>: Send + Sync {
///
/// # Returns
///
/// - `impl Future<Output` - Future of the merge operation.
/// - `impl Future<Output = ChunkStrategyResult>` - Future of the merge operation.
fn merge_chunks(&self) -> impl Future<Output = ChunkStrategyResult> + Send;
}
4 changes: 2 additions & 2 deletions color-output/src/color/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ impl<'a> ColorOutputList<'a> {
/// Provides an iterator over the elements in the internal `Vec<ColorOutput<'a>>`.
///
/// # Returns
/// - `std::slice::Iter<'_, ColorOutput<'a>>` - An iterator over references to `ColorOutput` elements.
/// - `Iter<'_, ColorOutput<'a>>` - An iterator over references to `ColorOutput` elements.
#[inline(always)]
pub fn iter(&self) -> std::slice::Iter<'_, ColorOutput<'a>> {
pub fn iter(&self) -> Iter<'_, ColorOutput<'a>> {
self.0.iter()
}

Expand Down
2 changes: 2 additions & 0 deletions color-output/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use std::{
borrow::Cow,
fmt::{self, Display},
io::Write,
io::stdout,
ops::Deref,
slice::Iter,
str::Lines,
};
2 changes: 1 addition & 1 deletion color-output/src/task/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'a> Task<'a> {
output_str.push_str(&Text::new_from(text).get_display_str_cow());
}
print!("{output_str}");
std::io::stdout().flush().unwrap();
stdout().flush().unwrap();
self
}
}
2 changes: 1 addition & 1 deletion color-output/src/utils/fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn __println_text(color: ColorType, bg_color: ColorType, text: &str) {
.color(color)
.bg_color(bg_color)
.build();
let lines: std::str::Lines<'_> = text.lines();
let lines: Lines<'_> = text.lines();
for line in lines {
let mut output_list_builder: ColorOutputListBuilder<'_> = ColorOutputListBuilder::new();
output_list_builder.add(time_output);
Expand Down
14 changes: 7 additions & 7 deletions compare-version/src/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Version {
pub(crate) fn parse(version: &str) -> Result<Self, VersionError> {
let mut parts: Vec<&str> = version.split('.').collect();
let (patch_part, pre_release) = if let Some(patch_with_prerelease) = parts.pop() {
let mut patch_parts: std::str::SplitN<'_, char> = patch_with_prerelease.splitn(2, '-');
let mut patch_parts: SplitN<'_, char> = patch_with_prerelease.splitn(2, '-');
(
patch_parts.next().unwrap_or(""),
patch_parts.next().map(|part: &str| part.to_string()),
Expand All @@ -49,15 +49,15 @@ impl Version {
.first()
.unwrap_or(&"0")
.parse::<u32>()
.map_err(|_: std::num::ParseIntError| VersionError::MajorVersionError)?;
.map_err(|_: ParseIntError| VersionError::MajorVersionError)?;
let minor: u32 = parts
.get(1)
.unwrap_or(&"0")
.parse::<u32>()
.map_err(|_: std::num::ParseIntError| VersionError::MinorVersionError)?;
.map_err(|_: ParseIntError| VersionError::MinorVersionError)?;
let patch: u32 = patch_part
.parse::<u32>()
.map_err(|_: std::num::ParseIntError| VersionError::PatchVersionError)?;
.map_err(|_: ParseIntError| VersionError::PatchVersionError)?;
Ok(Self {
major,
minor,
Expand All @@ -82,9 +82,9 @@ impl CompareVersion {
let v1: Version = Version::parse(version1)?;
let v2: Version = Version::parse(version2)?;
match v1.cmp(&v2) {
std::cmp::Ordering::Greater => Ok(VersionLevel::Greater),
std::cmp::Ordering::Less => Ok(VersionLevel::Less),
std::cmp::Ordering::Equal => Ok(VersionLevel::Equal),
Ordering::Greater => Ok(VersionLevel::Greater),
Ordering::Less => Ok(VersionLevel::Less),
Ordering::Equal => Ok(VersionLevel::Equal),
}
}

Expand Down
2 changes: 1 addition & 1 deletion compare-version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ pub use {r#enum::*, r#struct::*};

use r#const::*;

use std::fmt;
use std::{cmp::Ordering, fmt, num::ParseIntError, str::SplitN};
38 changes: 17 additions & 21 deletions crate-cli/src/bump/fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn expand_member_entry(root_dir: &Path, entry: &str) -> Vec<PathBuf> {
match entry.strip_suffix("/*") {
Some(prefix) => {
let mut dirs: Vec<PathBuf> = Vec::new();
if let Ok(entries) = std::fs::read_dir(root_dir.join(prefix)) {
if let Ok(entries) = fs::read_dir(root_dir.join(prefix)) {
for entry in entries.flatten() {
let path: PathBuf = entry.path();
if path.is_dir() && path.join(CARGO_TOML).exists() {
Expand Down Expand Up @@ -270,12 +270,12 @@ fn realign_dep_versions(
///
/// # Returns
///
/// - `Result<(), Box<dyn std::error::Error>>` - Success or error
/// - `Result<(), Box<dyn Error>>` - Success or error
async fn realign_member_manifest(
member_dir: &Path,
member_manifest_path: &Path,
bumped: &[(PathBuf, String)],
) -> Result<(), Box<dyn std::error::Error>> {
) -> Result<(), Box<dyn Error>> {
let member_content: String = read_to_string(member_manifest_path).await?;
let mut member_doc: DocumentMut = member_content.parse().map_err(|e: TomlError| {
format!("failed to parse {}: {}", member_manifest_path.display(), e)
Expand Down Expand Up @@ -344,12 +344,12 @@ async fn realign_member_manifest(
///
/// # Returns
///
/// - `Result<String, Box<dyn std::error::Error>>` - Summary string
/// - `Result<String, Box<dyn Error>>` - Summary string
async fn bump_workspace_members(
root_path: &Path,
doc: &mut DocumentMut,
bump_type: &BumpVersionType,
) -> Result<String, Box<dyn std::error::Error>> {
) -> Result<String, Box<dyn Error>> {
let root_dir: &Path = root_path.parent().unwrap_or_else(|| Path::new("."));
let member_entries: Vec<String> = doc
.get(TOML_WORKSPACE)
Expand Down Expand Up @@ -387,7 +387,7 @@ async fn bump_workspace_members(
let version_slot: &mut Item = member_doc
.get_mut(TOML_PACKAGE)
.and_then(|package: &mut Item| package.get_mut(TOML_VERSION))
.ok_or_else(|| -> Box<dyn std::error::Error> {
.ok_or_else(|| -> Box<dyn Error> {
format!(
"package.version not found in {}",
member_manifest_path.display()
Expand All @@ -397,11 +397,10 @@ async fn bump_workspace_members(
let Some(old_version) = version_slot.as_str().map(|s: &str| s.to_string()) else {
continue;
};
let new_version: String = bump_version_str(&old_version, bump_type).ok_or_else(
|| -> Box<dyn std::error::Error> {
let new_version: String =
bump_version_str(&old_version, bump_type).ok_or_else(|| -> Box<dyn Error> {
format!("failed to parse version: {}", old_version).into()
},
)?;
})?;
set_item_string_preserving_decor(version_slot, &new_version);
write(&member_manifest_path, member_doc.to_string()).await?;
log::info!(
Expand Down Expand Up @@ -451,12 +450,12 @@ async fn bump_workspace_members(
///
/// # Returns
///
/// - `Result<String, Box<dyn std::error::Error>>` - The new version string, a
/// - `Result<String, Box<dyn Error>>` - The new version string, a
/// workspace bump summary, or an error
pub async fn execute_bump(
manifest_path: &str,
bump_type: &BumpVersionType,
) -> Result<String, Box<dyn std::error::Error>> {
) -> Result<String, Box<dyn Error>> {
let path: &Path = Path::new(manifest_path);
let content: String = read_to_string(path).await?;
let mut doc: DocumentMut = content
Expand All @@ -480,24 +479,21 @@ pub async fn execute_bump(
doc.get_mut(TOML_WORKSPACE)
.and_then(|workspace: &mut Item| workspace.get_mut(TOML_PACKAGE))
.and_then(|package: &mut Item| package.get_mut(TOML_VERSION))
.ok_or_else(|| -> Box<dyn std::error::Error> {
ERROR_WORKSPACE_PACKAGE_VERSION_MISSING.into()
})?
.ok_or_else(|| -> Box<dyn Error> { ERROR_WORKSPACE_PACKAGE_VERSION_MISSING.into() })?
} else if has_root_package {
doc.get_mut(TOML_PACKAGE)
.and_then(|package: &mut Item| package.get_mut(TOML_VERSION))
.ok_or_else(|| -> Box<dyn std::error::Error> { ERROR_PACKAGE_VERSION_MISSING.into() })?
.ok_or_else(|| -> Box<dyn Error> { ERROR_PACKAGE_VERSION_MISSING.into() })?
} else {
return Err(ERROR_NO_VERSION_SLOT.into());
};
let version_str: String = version_slot
.as_str()
.ok_or_else(|| -> Box<dyn std::error::Error> { ERROR_VERSION_NOT_STRING.into() })?
.ok_or_else(|| -> Box<dyn Error> { ERROR_VERSION_NOT_STRING.into() })?
.to_string();
let version: Version =
parse_version(&version_str).ok_or_else(|| -> Box<dyn std::error::Error> {
format!("failed to parse version: {}", version_str).into()
})?;
let version: Version = parse_version(&version_str).ok_or_else(|| -> Box<dyn Error> {
format!("failed to parse version: {}", version_str).into()
})?;
let bumped: Version = bump_version(&version, bump_type);
let version_string: String = version_to_string(&bumped);
set_item_string_preserving_decor(version_slot, &version_string);
Expand Down
8 changes: 4 additions & 4 deletions crate-cli/src/fmt/fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn sort_derive_in_line(line: &str) -> Option<String> {
/// - `Result<bool, io::Error>` - True if file was modified, false otherwise
async fn format_derive_in_file(file_path: &Path) -> Result<bool, io::Error> {
let content: String = read_to_string(file_path).await?;
let lines: std::str::Lines<'_> = content.lines();
let lines: Lines<'_> = content.lines();
let mut modified: bool = false;
let mut new_content: String = String::new();
for line in lines {
Expand Down Expand Up @@ -169,7 +169,7 @@ fn is_cargo_clippy_installed() -> bool {
/// - `Result<(), io::Error>` - Success or error
async fn install_cargo_clippy() -> Result<(), io::Error> {
log::warn!("cargo-clippy not found, installing...");
let output: std::process::Output = Command::new(RUSTUP)
let output: Output = Command::new(RUSTUP)
.arg(RUSTUP_COMPONENT)
.arg("add")
.arg(CLIPPY)
Expand Down Expand Up @@ -230,7 +230,7 @@ async fn execute_clippy_fix(args: &Args) -> Result<(), io::Error> {
cmd.arg(CLI_FLAG_MANIFEST_PATH).arg(manifest_path);
}
cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
let output: std::process::Output = cmd.output().await?;
let output: Output = cmd.output().await?;
let stdout: String = String::from_utf8_lossy(&output.stdout).trim().to_string();
let stderr: String = String::from_utf8_lossy(&output.stderr).trim().to_string();
if !stdout.is_empty() {
Expand Down Expand Up @@ -287,7 +287,7 @@ pub async fn execute_fmt(args: &Args) -> Result<(), io::Error> {
cmd.arg(CLI_FLAG_MANIFEST_PATH).arg(manifest_path);
}
cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
let output: std::process::Output = cmd.output().await?;
let output: Output = cmd.output().await?;
let stdout: String = String::from_utf8_lossy(&output.stdout).trim().to_string();
let stderr: String = String::from_utf8_lossy(&output.stderr).trim().to_string();
if !stdout.is_empty() {
Expand Down
5 changes: 5 additions & 0 deletions crate-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ pub(crate) use {
toml_edit::{DocumentMut, Item, TableLike, TomlError, value},
which::which,
};

use std::{
error::Error, fmt::Arguments, fs, process::Output, str::Lines, str::Split,
str::SplitWhitespace, time::SystemTime, time::UNIX_EPOCH,
};
2 changes: 1 addition & 1 deletion crate-cli/src/logger/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl log::Log for Logger {
}
let now_time: String = color_output::time();
let level: log::Level = record.level();
let args: &std::fmt::Arguments<'_> = record.args();
let args: &Arguments<'_> = record.args();
let file: Option<&str> = record.file();
let module_path: Option<&str> = record.module_path();
let target: &str = record.target();
Expand Down
15 changes: 6 additions & 9 deletions crate-cli/src/publish/fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ pub fn parse_rate_limit_wait_secs(stderr: &str) -> Option<u64> {
let start: usize = stderr.find(STDERR_TRY_AGAIN_AFTER)? + STDERR_TRY_AGAIN_AFTER.len();
let end: usize = start + stderr[start..].find(STDERR_TRY_AGAIN_AFTER_END)?;
let timestamp: &str = stderr[start..end].trim();
let mut tokens: std::str::SplitWhitespace<'_> = timestamp.split_whitespace();
let mut tokens: SplitWhitespace<'_> = timestamp.split_whitespace();
let _: &str = tokens.next()?;
let day: i64 = tokens
.next()?
Expand All @@ -435,16 +435,13 @@ pub fn parse_rate_limit_wait_secs(stderr: &str) -> Option<u64> {
.position(|name: &&str| *name == month_token)? as i64
+ 1;
let year: i64 = tokens.next()?.parse().ok()?;
let mut clock_fields: std::str::Split<'_, char> = tokens.next()?.split(CLOCK_FIELD_SEPARATOR);
let mut clock_fields: Split<'_, char> = tokens.next()?.split(CLOCK_FIELD_SEPARATOR);
let hour: i64 = clock_fields.next()?.parse().ok()?;
let minute: i64 = clock_fields.next()?.parse().ok()?;
let second: i64 = clock_fields.next()?.parse().ok()?;
let day_start: i64 = civil_to_days(year, month, day) * SECONDS_PER_DAY;
let deadline: i64 = day_start + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second;
let now: i64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.ok()?
.as_secs() as i64;
let now: i64 = SystemTime::now().duration_since(UNIX_EPOCH).ok()?.as_secs() as i64;
let remaining: i64 = deadline - now;
// A parsed deadline is honoured as given, in either direction: a window
// the registry says is shorter than the skew allowance is already open
Expand Down Expand Up @@ -538,9 +535,9 @@ async fn publish_package_with_retry(package: &Package, max_retries: u32) -> Publ
///
/// # Returns
///
/// - `Result<(), Box<dyn std::error::Error>>` - Success or error
async fn publish_single_package(package: &Package) -> Result<(), Box<dyn std::error::Error>> {
let output: std::process::Output = Command::new(CARGO)
/// - `Result<(), Box<dyn Error>>` - Success or error
async fn publish_single_package(package: &Package) -> Result<(), Box<dyn Error>> {
let output: Output = Command::new(CARGO)
.arg(CARGO_PUBLISH)
.arg(CLI_FLAG_ALLOW_DIRTY)
.arg(CLI_FLAG_NO_VERIFY)
Expand Down
Loading
Loading