Struct rlua::String [] [src]

pub struct String<'lua>(_);

Handle to an internal Lua string.

Unlike Rust strings, Lua strings may not be valid UTF-8.

Methods

impl<'lua> String<'lua>
[src]

[src]

Get a &str slice if the Lua string is valid UTF-8.

Examples

let lua = Lua::new();
let globals = lua.globals();

let version: String = globals.get("_VERSION")?;
assert!(version.to_str().unwrap().contains("Lua"));

let non_utf8: String = lua.eval(r#"  "test\xff"  "#, None)?;
assert!(non_utf8.to_str().is_err());

[src]

Get the bytes that make up this string.

The returned slice will not contain the terminating null byte, but will contain any null bytes embedded into the Lua string.

Examples

let lua = Lua::new();

let non_utf8: String = lua.eval(r#"  "test\xff"  "#, None).unwrap();
assert!(non_utf8.to_str().is_err());    // oh no :(
assert_eq!(non_utf8.as_bytes(), &b"test\xff"[..]);

Trait Implementations

impl<'lua> Clone for String<'lua>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'lua> Debug for String<'lua>
[src]

[src]

Formats the value using the given formatter.

impl<'lua> ToLua<'lua> for String<'lua>
[src]

[src]

Performs the conversion.

impl<'lua> FromLua<'lua> for String<'lua>
[src]

[src]

Performs the conversion.