Skip to content

Commit

Permalink
🐎 use String::from
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Nov 4, 2024
1 parent c29e8be commit c8fafb5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cli/src/chunk/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl FromStr for AcePlatform {
"macos" => Ok(Self::MacOs),
"linux" => Ok(Self::Linux),
"freebsd" => Ok(Self::FreeBSD),
s => Ok(Self::Unknown(s.to_string())),
s => Ok(Self::Unknown(s.into())),
}
}
}
Expand Down Expand Up @@ -222,20 +222,20 @@ impl FromStr for Ace {
let owner = match owner_type {
"u" | "user" => match owner_name {
"" => OwnerType::Owner,
name => OwnerType::User(Identifier(name.to_string())),
name => OwnerType::User(Identifier(name.into())),
},
"g" | "group" => match owner_name {
"" => OwnerType::OwnerGroup,
name => OwnerType::Group(Identifier(name.to_string())),
name => OwnerType::Group(Identifier(name.into())),
},
"m" | "mask" => OwnerType::Mask,
"o" | "other" => OwnerType::Other,
o => return Err(Self::Err::UnexpectedOwnerType(o.to_string())),
o => return Err(Self::Err::UnexpectedOwnerType(o.into())),
};
let allow = match it.next().ok_or(Self::Err::NotEnoughElement)? {
"allow" => true,
"deny" => false,
a => return Err(Self::Err::UnexpectedAccessControl(a.to_string())),
a => return Err(Self::Err::UnexpectedAccessControl(a.into())),
};
let mut permissions = it.next().ok_or(ParseAceError::NotEnoughElement)?.split(',');
let mut permission = Permission::empty();
Expand Down
18 changes: 9 additions & 9 deletions cli/src/command/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ where
let metadata = entry.metadata();
Ok(Self {
encryption: match solid.map(|s| s.encryption()).unwrap_or(header.encryption()) {
Encryption::No => "-".to_string(),
Encryption::No => "-".into(),
_ => format!("{:?}({:?})", header.encryption(), header.cipher_mode())
.to_ascii_lowercase(),
},
Expand All @@ -135,8 +135,8 @@ where
.unwrap_or(header.compression()),
solid,
) {
(Compression::No, None) => "-".to_string(),
(Compression::No, Some(_)) => "-(solid)".to_string(),
(Compression::No, None) => "-".into(),
(Compression::No, Some(_)) => "-(solid)".into(),
(method, None) => format!("{:?}", method).to_ascii_lowercase(),
(method, Some(_)) => format!("{:?}(solid)", method).to_ascii_lowercase(),
},
Expand All @@ -154,20 +154,20 @@ where
if numeric_owner {
p.uid().to_string()
} else {
p.uname().to_string()
p.uname().into()
}
})
.unwrap_or_else(|| "-".to_string()),
.unwrap_or_else(|| "-".into()),
group: metadata
.permission()
.map(|p| {
if numeric_owner {
p.gid().to_string()
} else {
p.gname().to_string()
p.gname().into()
}
})
.unwrap_or_else(|| "-".to_string()),
.unwrap_or_else(|| "-".into()),
created: datetime(now, metadata.created()),
modified: datetime(now, metadata.modified()),
name: if matches!(
Expand All @@ -177,7 +177,7 @@ where
let path = header.path().to_string();
let original = entry
.reader(ReadOptions::with_password(password))
.map(|r| io::read_to_string(r).unwrap_or_else(|_| "-".to_string()))
.map(|r| io::read_to_string(r).unwrap_or_else(|_| "-".into()))
.unwrap_or_default();
format!("{} -> {}", path, original)
} else {
Expand Down Expand Up @@ -445,7 +445,7 @@ fn within_six_months(now: SystemTime, x: SystemTime) -> bool {

fn datetime(now: SystemTime, d: Option<Duration>) -> String {
match d {
None => "-".to_string(),
None => "-".into(),
Some(d) => {
let time = UNIX_EPOCH + d;
let datetime = DateTime::<Local>::from(time);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utils/os/unix/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl Into<exacl::AclEntry> for Ace {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
OwnerType::Mask => (exacl::AclEntryKind::Mask, String::new()),
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
OwnerType::Other => (exacl::AclEntryKind::Group, "everyone".to_string()),
OwnerType::Other => (exacl::AclEntryKind::Group, "everyone".into()),
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
OwnerType::Other => (exacl::AclEntryKind::Other, String::new()),
};
Expand Down

0 comments on commit c8fafb5

Please sign in to comment.