uv/crates/uv-configuration/src/dry_run.rs
adamnemecek 3f83390e34
Make the use of Self consistent. (#15074)
## Summary

Make the use of `Self` consistent. Mostly done by running `cargo clippy
--fix -- -A clippy::all -W clippy::use_self`.

## Test Plan

<!-- How was it tested? -->
No need.
2025-08-05 20:17:12 +01:00

27 lines
760 B
Rust

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum DryRun {
/// The operation should execute in dry run mode.
Enabled,
/// The operation should execute in dry run mode and check if the current environment is
/// synced.
Check,
/// The operation should execute in normal mode.
#[default]
Disabled,
}
impl DryRun {
/// Determine the [`DryRun`] setting based on the command-line arguments.
pub fn from_args(dry_run: bool) -> Self {
if dry_run {
Self::Enabled
} else {
Self::Disabled
}
}
/// Returns `true` if dry run mode is enabled.
pub const fn enabled(&self) -> bool {
matches!(self, Self::Enabled) || matches!(self, Self::Check)
}
}