mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
fix clippy in cp
This commit is contained in:
parent
97d12d6e3c
commit
75a76613e4
1 changed files with 8 additions and 6 deletions
|
@ -132,7 +132,9 @@ macro_rules! prompt_yes(
|
||||||
|
|
||||||
pub type CopyResult<T> = Result<T, Error>;
|
pub type CopyResult<T> = Result<T, Error>;
|
||||||
pub type Source = PathBuf;
|
pub type Source = PathBuf;
|
||||||
|
pub type SourceSlice = Path;
|
||||||
pub type Target = PathBuf;
|
pub type Target = PathBuf;
|
||||||
|
pub type TargetSlice = Path;
|
||||||
|
|
||||||
/// Specifies whether when overwrite files
|
/// Specifies whether when overwrite files
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
#[derive(Clone, Eq, PartialEq)]
|
||||||
|
@ -664,7 +666,7 @@ impl TargetType {
|
||||||
///
|
///
|
||||||
/// Treat target as a dir if we have multiple sources or the target
|
/// Treat target as a dir if we have multiple sources or the target
|
||||||
/// exists and already is a directory
|
/// exists and already is a directory
|
||||||
fn determine(sources: &[Source], target: &Target) -> TargetType {
|
fn determine(sources: &[Source], target: &TargetSlice) -> TargetType {
|
||||||
if sources.len() > 1 || target.is_dir() {
|
if sources.len() > 1 || target.is_dir() {
|
||||||
TargetType::Directory
|
TargetType::Directory
|
||||||
} else {
|
} else {
|
||||||
|
@ -787,7 +789,7 @@ fn preserve_hardlinks(
|
||||||
/// Behavior depends on `options`, see [`Options`] for details.
|
/// Behavior depends on `options`, see [`Options`] for details.
|
||||||
///
|
///
|
||||||
/// [`Options`]: ./struct.Options.html
|
/// [`Options`]: ./struct.Options.html
|
||||||
fn copy(sources: &[Source], target: &Target, options: &Options) -> CopyResult<()> {
|
fn copy(sources: &[Source], target: &TargetSlice, options: &Options) -> CopyResult<()> {
|
||||||
let target_type = TargetType::determine(sources, target);
|
let target_type = TargetType::determine(sources, target);
|
||||||
verify_target_type(target, &target_type)?;
|
verify_target_type(target, &target_type)?;
|
||||||
|
|
||||||
|
@ -839,7 +841,7 @@ fn copy(sources: &[Source], target: &Target, options: &Options) -> CopyResult<()
|
||||||
|
|
||||||
fn construct_dest_path(
|
fn construct_dest_path(
|
||||||
source_path: &Path,
|
source_path: &Path,
|
||||||
target: &Target,
|
target: &TargetSlice,
|
||||||
target_type: &TargetType,
|
target_type: &TargetType,
|
||||||
options: &Options,
|
options: &Options,
|
||||||
) -> CopyResult<PathBuf> {
|
) -> CopyResult<PathBuf> {
|
||||||
|
@ -869,8 +871,8 @@ fn construct_dest_path(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_source(
|
fn copy_source(
|
||||||
source: &Source,
|
source: &SourceSlice,
|
||||||
target: &Target,
|
target: &TargetSlice,
|
||||||
target_type: &TargetType,
|
target_type: &TargetType,
|
||||||
options: &Options,
|
options: &Options,
|
||||||
) -> CopyResult<()> {
|
) -> CopyResult<()> {
|
||||||
|
@ -911,7 +913,7 @@ fn adjust_canonicalization(p: &Path) -> Cow<Path> {
|
||||||
///
|
///
|
||||||
/// Any errors encountered copying files in the tree will be logged but
|
/// Any errors encountered copying files in the tree will be logged but
|
||||||
/// will not cause a short-circuit.
|
/// will not cause a short-circuit.
|
||||||
fn copy_directory(root: &Path, target: &Target, options: &Options) -> CopyResult<()> {
|
fn copy_directory(root: &Path, target: &TargetSlice, options: &Options) -> CopyResult<()> {
|
||||||
if !options.recursive {
|
if !options.recursive {
|
||||||
return Err(format!("omitting directory '{}'", root.display()).into());
|
return Err(format!("omitting directory '{}'", root.display()).into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue