summaryrefslogtreecommitdiff
path: root/src/lua.rs
diff options
context:
space:
mode:
authorkyren <kerriganw@gmail.com>2018-09-30 15:42:04 -0400
committerkyren <kerriganw@gmail.com>2018-09-30 15:42:04 -0400
commit167184ae76b37b53114f2818bbc48c83936a08f4 (patch)
tree153ac4ee37ff171a6c88770bd7c0e00b7d359ed7 /src/lua.rs
parent8810c36979be268b1feede78a24e3f1ba5054271 (diff)
downloadmlua-167184ae76b37b53114f2818bbc48c83936a08f4.zip
Allow arbitrary [u8] Lua strings
Diffstat (limited to 'src/lua.rs')
-rw-r--r--src/lua.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lua.rs b/src/lua.rs
index c13eb2d..846ce3a 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -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);