Struct emacs::OnceGlobalRef

source ·
pub struct OnceGlobalRef { /* private fields */ }
Expand description

A GlobalRef that can be initialized once. This is useful for long-lived values that should be initialized when the dynamic module is loaded. A typical use case is specifying frequently-used symbols, which can be done with the help of the macro use_symbols!.

Implementations§

source§

impl OnceGlobalRef

source

pub const fn new() -> Self

Methods from Deref<Target = GlobalRef>§

source

pub fn call<'e, A>(&'e self, env: &'e Env, args: A) -> Result<Value<'_>>
where A: IntoLispArgs<'e>,

Calls this reference’s value with the given arguments. An error is signaled if it is actually not a Lisp’s callable.

args should be an array/slice of Value, or a tuple of different types, each implementing IntoLisp.

source

pub unsafe fn call_unprotected<'e, A>( &'e self, env: &'e Env, args: A ) -> Result<Value<'_>>
where A: IntoLispArgs<'e>,

Like call, except that the returned Value is not protected against Emacs GC’s bug #31238, which caused issue #2.

§Safety

This can be used as an optimization, in situations when the returned Value is unused, or when its usage is shorter than the lifespan of the underlying Lisp object.

source

pub fn bind<'e, 'g: 'e>(&'g self, env: &'e Env) -> Value<'e>

Returns the underlying Value, scoping its lifetime to the given Env.

source

pub fn clone(&self, env: &Env) -> Self

Returns a copy of this global reference.

Trait Implementations§

source§

impl Debug for OnceGlobalRef

source§

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

Formats the value using the given formatter. Read more
source§

impl Deref for OnceGlobalRef

§

type Target = GlobalRef

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'e> IntoLisp<'e> for &'e OnceGlobalRef

source§

fn into_lisp(self, env: &'e Env) -> Result<Value<'e>>

Auto Trait Implementations§

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> 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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.