pub struct Strict<T>(pub T);Expand description
A host parameter that takes the Lua kind its Teal type names, and converts nothing.
mlua’s FromLua for i64 accepts a Lua string and coerces it ("10" arrives as
10), and its FromLua for String accepts a number and formats it. The .d.tl
that #[host_module] writes says integer and string, and checked Teal cannot pass
the other kind — but a value from past a cast or a load, which the checker did not
see, can, and the host has no way to tell the two apart once mlua has converted.
Strict<T> is the parameter type that keeps the runtime to the declaration: an
integer is Value::Integer, or a Value::Number with no fraction (as
math.tointeger reads it); a float is either number kind; bool is
Value::Boolean; String is Value::String. Anything else is a conversion error
naming what arrived — error converting Lua string to integer — the same shape mlua
reports, so a caller reading errors sees one kind of message.
#[host_module(name = "api")]
impl Api {
pub fn take(&self, n: Strict<i64>) -> i64 { *n } // `take: function(self: api, n: integer): integer`
}The declaration is the inner type’s — Strict<i64> is integer in the .d.tl — since
it already said that; this only holds the runtime to it. Derefs to T, and goes back
to Lua as T would, so a return type may be Strict<T> as well, though there it
adds nothing.
The other two layers of the same question are the checker, which holds checked Teal,
and Htl::strict_strings, which holds the program state
where arithmetic on a string would otherwise convert.
Tuple Fields§
§0: TImplementations§
Source§impl<T> Strict<T>
impl<T> Strict<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
The value, out of the wrapper.
Trait Implementations§
impl<T: Copy> Copy for Strict<T>
impl<T: Eq> Eq for Strict<T>
Source§impl<T: StrictKind> FromLua for Strict<T>
impl<T: StrictKind> FromLua for Strict<T>
Source§impl<T: Ord> Ord for Strict<T>
impl<T: Ord> Ord for Strict<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd> PartialOrd for Strict<T>
impl<T: PartialOrd> PartialOrd for Strict<T>
impl<T: PartialEq> StructuralPartialEq for Strict<T>
Auto Trait Implementations§
impl<T> Freeze for Strict<T>where
T: Freeze,
impl<T> RefUnwindSafe for Strict<T>where
T: RefUnwindSafe,
impl<T> Send for Strict<T>where
T: Send,
impl<T> Sync for Strict<T>where
T: Sync,
impl<T> Unpin for Strict<T>where
T: Unpin,
impl<T> UnsafeUnpin for Strict<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Strict<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromLuaMulti for Twhere
T: FromLua,
impl<T> FromLuaMulti for Twhere
T: FromLua,
Source§fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>
unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>
unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more