diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2023-07-09 14:58:37 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2023-07-09 22:11:26 +0100 |
commit | 1c20494158e7ac10e8edda2c510b2168ff5de046 (patch) | |
tree | 836a91d5100fc3101ddc4e19cbd438c5103fb296 /src/serde/ser.rs | |
parent | c9294ad642c7dec103cc82d2f37f5985a25b98ab (diff) | |
download | mlua-1c20494158e7ac10e8edda2c510b2168ff5de046.zip |
Use usize instead of c_int for table capacity (Lua::create_table_with_capacity)
Diffstat (limited to 'src/serde/ser.rs')
-rw-r--r-- | src/serde/ser.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/serde/ser.rs b/src/serde/ser.rs index 9b4a3aa..6115cb2 100644 --- a/src/serde/ser.rs +++ b/src/serde/ser.rs @@ -1,5 +1,3 @@ -use std::os::raw::c_int; - use serde::{ser, Serialize}; use super::LuaSerdeExt; @@ -233,8 +231,7 @@ impl<'lua> ser::Serializer for Serializer<'lua> { #[inline] fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq> { - let len = len.unwrap_or(0) as c_int; - let table = self.lua.create_table_with_capacity(len, 0)?; + let table = self.lua.create_table_with_capacity(len.unwrap_or(0), 0)?; if self.options.set_array_metatable { table.set_metatable(Some(self.lua.array_metatable())); } @@ -277,10 +274,9 @@ impl<'lua> ser::Serializer for Serializer<'lua> { #[inline] fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap> { - let len = len.unwrap_or(0) as c_int; Ok(SerializeMap { key: None, - table: self.lua.create_table_with_capacity(0, len)?, + table: self.lua.create_table_with_capacity(0, len.unwrap_or(0))?, options: self.options, }) } @@ -300,7 +296,7 @@ impl<'lua> ser::Serializer for Serializer<'lua> { ) -> Result<Self::SerializeStructVariant> { Ok(SerializeStructVariant { name: self.lua.create_string(variant)?, - table: self.lua.create_table_with_capacity(0, len as c_int)?, + table: self.lua.create_table_with_capacity(0, len)?, options: self.options, }) } |