diff options
author | kyren <kerriganw@gmail.com> | 2018-09-30 15:42:04 -0400 |
---|---|---|
committer | kyren <kerriganw@gmail.com> | 2018-09-30 15:42:04 -0400 |
commit | 167184ae76b37b53114f2818bbc48c83936a08f4 (patch) | |
tree | 153ac4ee37ff171a6c88770bd7c0e00b7d359ed7 /src/lua.rs | |
parent | 8810c36979be268b1feede78a24e3f1ba5054271 (diff) | |
download | mlua-167184ae76b37b53114f2818bbc48c83936a08f4.zip |
Allow arbitrary [u8] Lua strings
Diffstat (limited to 'src/lua.rs')
-rw-r--r-- | src/lua.rs | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -140,8 +140,10 @@ impl Lua { .call(()) } - /// Pass a `&str` slice to Lua, creating and returning an interned Lua string. - pub fn create_string(&self, s: &str) -> Result<String> { + /// Create and return an interned Lua string. Lua strings can be arbitrary [u8] data including + /// embedded nulls, so in addition to `&str` and `&String`, you can also pass plain `&[u8]` + /// here. + pub fn create_string<S: ?Sized + AsRef<[u8]>>(&self, s: &S) -> Result<String> { unsafe { let _sg = StackGuard::new(self.state); assert_stack(self.state, 4); |