[−][src]Struct rlua::String
Handle to an internal Lua string.
Unlike Rust strings, Lua strings may not be valid UTF-8.
Methods
impl<'lua> String<'lua>
[src]
pub fn to_str(&self) -> Result<&str>
[src]
Get a &str
slice if the Lua string is valid UTF-8.
Examples
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());
pub fn as_bytes(&self) -> &[u8]
[src]
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.
Examples
let non_utf8: String = lua_context.load(r#" "test\xff" "#).eval()?; assert!(non_utf8.to_str().is_err()); // oh no :( assert_eq!(non_utf8.as_bytes(), &b"test\xff"[..]);
pub fn as_bytes_with_nul(&self) -> &[u8]
[src]
Get the bytes that make up this string, including the trailing nul byte.
Trait Implementations
impl<'lua> ToLua<'lua> for String<'lua>
[src]
impl<'lua> FromLua<'lua> for String<'lua>
[src]
impl<'lua> Clone for String<'lua>
[src]
fn clone(&self) -> String<'lua>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'lua, T> PartialEq<T> for String<'lua> where
T: AsRef<[u8]>,
[src]
T: AsRef<[u8]>,
fn eq(&self, other: &T) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=
.
impl<'lua> AsRef<[u8]> for String<'lua>
[src]
impl<'lua> Debug for String<'lua>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,