Skip to content

Commit

Permalink
fixup: Use surrounding match block instead of separate if matches!
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed May 13, 2021
1 parent fc60f9b commit f2db976
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 32 deletions.
20 changes: 9 additions & 11 deletions src/analysis/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,18 +603,16 @@ impl<'env> RustTypeBuilder<'env> {
.with_try_from_glib(&self.try_from_glib)
.try_build();
match type_ {
Fundamental(fund) => {
if matches!(
fund,
library::Fundamental::Utf8
| library::Fundamental::OsString
| library::Fundamental::Filename
) && (self.direction == ParameterDirection::InOut
Fundamental(library::Fundamental::Utf8)
| Fundamental(library::Fundamental::OsString)
| Fundamental(library::Fundamental::Filename)
if (self.direction == ParameterDirection::InOut
|| (self.direction == ParameterDirection::Out
&& self.ref_mode == RefMode::ByRefMut))
{
return Err(TypeError::Unimplemented(into_inner(rust_type)));
}
&& self.ref_mode == RefMode::ByRefMut)) =>
{
Err(TypeError::Unimplemented(into_inner(rust_type)))
}
Fundamental(_) => {
rust_type.map_any(|rust_type| rust_type.format_parameter(self.direction))
}

Expand Down
22 changes: 6 additions & 16 deletions src/codegen/function_body_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,14 +1263,9 @@ fn c_type_mem_mode_lib(
use crate::library::Type::*;
let type_ = env.library.type_(typ);
match type_ {
Fundamental(fund)
if matches!(
fund,
library::Fundamental::Utf8
| library::Fundamental::OsString
| library::Fundamental::Filename
) =>
{
Fundamental(library::Fundamental::Utf8)
| Fundamental(library::Fundamental::OsString)
| Fundamental(library::Fundamental::Filename) => {
if transfer == library::Transfer::Full {
NullMutPtr
} else {
Expand Down Expand Up @@ -1305,14 +1300,9 @@ fn type_mem_mode(env: &Env, parameter: &library::Parameter) -> Chunk {
use crate::library::Type::*;
let type_ = env.library.type_(parameter.typ);
match type_ {
Fundamental(fund)
if matches!(
fund,
library::Fundamental::Utf8
| library::Fundamental::OsString
| library::Fundamental::Filename
) =>
{
Fundamental(library::Fundamental::Utf8)
| Fundamental(library::Fundamental::OsString)
| Fundamental(library::Fundamental::Filename) => {
if parameter.transfer == library::Transfer::Full {
Chunk::NullMutPtr
} else {
Expand Down
9 changes: 4 additions & 5 deletions src/codegen/trampoline_from_glib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ pub fn from_glib_xxx(transfer: library::Transfer, is_borrow: bool) -> (String, S
fn is_need_type_name(env: &Env, type_id: library::TypeId) -> bool {
if type_id.ns_id == library::INTERNAL_NAMESPACE {
use crate::library::{Fundamental::*, Type::*};
match env.type_(type_id) {
// Fundamental(Utf8 | Filename | OsString) => true,
Fundamental(Utf8) | Fundamental(Filename) | Fundamental(OsString) => true,
_ => false,
}
matches!(
env.type_(type_id),
Fundamental(Utf8) | Fundamental(Filename) | Fundamental(OsString)
)
} else {
false
}
Expand Down

0 comments on commit f2db976

Please sign in to comment.