Skip to main content

Reg

Struct Reg 

Source
pub struct Reg(/* private fields */);
Expand description

Safe wrapper for luaL_Reg, used in module creation.

This type is usually contained within a &[Reg], these slices can be generated easily using the reg! macro or created manually using Reg::new and Reg::END.

See also the reg! macro.

Implementations§

Source§

impl Reg

Source

pub const END: Self

The terminator of a Reg slice. All slices must have the terminator as their last element.

reg! automatically appends the terminator to the generated slice.

Source

pub const fn new(name: &'static CStr, func: CFunction) -> Self

Manually creates a new Reg element intended to be inserted into a slice.

This function is internally called for you by reg!.

Source

pub const unsafe fn from_raw(raw: luaL_Reg) -> Self

Wraps a pre-existing raw luaL_Reg.

§Safety
  • name must either be null or a valid string pointer.
  • func must either be None or safe to call.

A non-modified luaL_Reg obtained from Reg::into_raw should always be safe to use.

Source

pub const fn into_raw(self) -> luaL_Reg

Returns the wrapped luaL_Reg.

The raw luaL_Reg can be safely converted back into a Reg using Reg::from_raw, as long as it is not modified.

Source

pub const fn name(&self) -> Option<&'static CStr>

Returns the stored function name.

Reg::END will return None instead.

Source

pub const fn func(&self) -> Option<CFunction>

Returns the stored function.

Reg::END will return None instead.

Source

pub const fn is_end(&self) -> bool

Returns true if this Reg is equal to Reg::END, false otherwise.

Trait Implementations§

Source§

impl Clone for Reg

Source§

fn clone(&self) -> Reg

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Reg

Source§

impl Debug for Reg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Send for Reg

§

impl !Sync for Reg

§

impl Freeze for Reg

§

impl RefUnwindSafe for Reg

§

impl Unpin for Reg

§

impl UnsafeUnpin for Reg

§

impl UnwindSafe for Reg

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.