From bf9fcc5aca35f889717a90a309129dbad8da3049 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Fri, 22 Nov 2024 13:06:50 +0000 Subject: [PATCH] Simplify `WrappedString` --- src/string.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/string.rs b/src/string.rs index f4730a9..47af717 100644 --- a/src/string.rs +++ b/src/string.rs @@ -368,23 +368,20 @@ impl<'a> IntoIterator for BorrowedBytes<'a> { } } -pub(crate) struct WrappedString Result>(F); +pub(crate) struct WrappedString>(T); impl String { /// Wraps bytes, returning an opaque type that implements [`IntoLua`] trait. /// /// This function uses [`Lua::create_string`] under the hood. pub fn wrap(data: impl AsRef<[u8]>) -> impl IntoLua { - WrappedString(move |lua| lua.create_string(data)) + WrappedString(data) } } -impl IntoLua for WrappedString -where - F: FnOnce(&Lua) -> Result, -{ +impl> IntoLua for WrappedString { fn into_lua(self, lua: &Lua) -> Result { - (self.0)(lua).map(Value::String) + lua.create_string(self.0).map(Value::String) } }