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 a04cc7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 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

0 comments on commit a04cc7c

Please sign in to comment.