1
0
Fork 0
forked from wry/wry

all: use let chains

This commit is contained in:
Julian Orth 2025-07-01 11:20:48 +02:00
parent 3d5d146d65
commit 286857971a
89 changed files with 1516 additions and 1574 deletions

View file

@ -17,12 +17,11 @@ fn create_bridge() -> anyhow::Result<()> {
fn create_version() -> anyhow::Result<()> {
let mut version_string = env!("CARGO_PKG_VERSION").to_string();
if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output() {
if output.status.success() {
if let Ok(commit) = std::str::from_utf8(&output.stdout) {
write!(version_string, " ({})", commit.trim())?;
}
}
if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output()
&& output.status.success()
&& let Ok(commit) = std::str::from_utf8(&output.stdout)
{
write!(version_string, " ({})", commit.trim())?;
}
let mut f = open("version.rs")?;
writeln!(f, "pub const VERSION: &str = \"{}\";", version_string)?;

View file

@ -595,13 +595,12 @@ fn struct_needs_lt(s: &Struct, protocols: &Protocols) -> Result<bool> {
}
let mut needs_lt = false;
for field in &s.fields {
if let Field::Real(f) = field {
if f.value.is_none() {
if needs_lifetime(&f.ty, protocols)? {
needs_lt = true;
break;
}
}
if let Field::Real(f) = field
&& f.value.is_none()
&& needs_lifetime(&f.ty, protocols)?
{
needs_lt = true;
break;
}
}
s.needs_lt.set(Some(needs_lt));
@ -674,11 +673,11 @@ fn struct_has_fds(s: &Struct, protocols: &Protocols) -> Result<bool> {
}
let mut has_fds = false;
for field in &s.fields {
if let Field::Real(f) = field {
if type_has_fds(&f.ty, protocols)? {
has_fds = true;
break;
}
if let Field::Real(f) = field
&& type_has_fds(&f.ty, protocols)?
{
has_fds = true;
break;
}
}
s.has_fds.set(Some(has_fds));
@ -1519,10 +1518,10 @@ fn format_struct<F: Write>(
}
writeln!(f, " Ok(Self {{")?;
for field in &s.fields {
if let Field::Real(rf) = field {
if rf.value.is_none() {
writeln!(f, " {},", rf.name)?;
}
if let Field::Real(rf) = field
&& rf.value.is_none()
{
writeln!(f, " {},", rf.name)?;
}
}
writeln!(f, " }})")?;