From ee4b75d66d94c989c7295521e7259f7785518b9b Mon Sep 17 00:00:00 2001 From: BiagioFesta <15035284+BiagioFesta@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:16:28 +0200 Subject: [PATCH] codegen/function: body future handles ownership of slice argument --- src/codegen/function.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/codegen/function.rs b/src/codegen/function.rs index f5f4b5c3d..9d5340afe 100644 --- a/src/codegen/function.rs +++ b/src/codegen/function.rs @@ -438,9 +438,12 @@ pub fn body_chunk_futures( let c_par = &analysis.parameters.c_parameters[par.ind_c]; let type_ = env.type_(par.typ); - let is_str = matches!(*type_, library::Type::Basic(library::Basic::Utf8)); + let is_str = matches!(type_, library::Type::Basic(library::Basic::Utf8)); + let is_slice = matches!(type_, library::Type::CArray(_)); - if *c_par.nullable { + if is_slice { + writeln!(body, "let {} = {}.to_vec();", par.name, par.name)?; + } else if *c_par.nullable { writeln!( body, "let {} = {}.map(ToOwned::to_owned);",