pub struct String<'lua>(_);
Handle to an internal Lua string.
Unlike Rust strings, Lua strings may not be valid UTF-8.
Get a &str
slice if the Lua string is valid UTF-8.
let globals = lua_context.globals();
let version: String = globals.get("_VERSION")?;
assert!(version.to_str().unwrap().contains("Lua"));
let non_utf8: String = lua_context.load(r#" "test\xff" "#).eval()?;
assert!(non_utf8.to_str().is_err());
Get the bytes that make up this string.
The returned slice will not contain the terminating nul byte, but will contain any nul
bytes embedded into the Lua string.
let non_utf8: String = lua_context.load(r#" "test\xff" "#).eval()?;
assert!(non_utf8.to_str().is_err());
assert_eq!(non_utf8.as_bytes(), &b"test\xff"[..]);
Get the bytes that make up this string, including the trailing nul byte.
Performs copy-assignment from source
. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static