Struct key_native::Class

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

原生类型指针

Implementations§

source§

impl Class

source

pub const fn uninit() -> Self

为static创建一个空指针

要在此后调用其new方法才能访问

source

pub fn new(&self, name: &str)

为Class内部创建一个新类

重复调用会引起一个ClassInner的内存泄漏

source

pub fn create_raw(&self, v: usize, w: usize) -> Instance

为此类创建一个实例

v是两个指针长度的内容,可以传任何东西然后as或者transmute

source

pub fn create(&self, v: usize, w: usize) -> Litr

为此类创建一个实例并包装为Litr

v是两个指针长度的内容,可以传任何东西然后as或者transmute

source

pub fn getter(&self, f: fn(_: &Instance, get: Ident) -> Litr)

设置getter, 用来处理.运算符

source

pub fn setter(&self, f: fn(_: &mut Instance, set: Ident, to: Litr))

设置setter, 用来处理a.b = c的写法

source

pub fn index_get(&self, f: fn(_: &Instance, _: LitrRef) -> Litr)

设置index getter, 返回a[i]的值

source

pub fn index_set(&self, f: fn(_: &mut Instance, _: LitrRef, _: Litr))

设置index setter, 处理a[i] = b

source

pub fn next(&self, f: fn(_: &mut Instance) -> Litr)

设置迭代器, 处理for n:instance {}

source

pub fn onclone(&self, f: fn(_: &Instance) -> Instance)

自定义复制行为(往往是赋值和传参)

source

pub fn ondrop(&self, f: fn(_: &mut Instance))

自定义垃圾回收回收行为(只需要写额外工作,不需要drop此指针)

source

pub fn to_str(&self, f: fn(_: &Instance) -> String)

自定义Str::from得到的字符串

source

pub fn method(&self, name: &str, f: NativeMethod)

添加一个方法

source

pub fn static_method(&self, name: &str, f: NativeFn)

添加一个静态方法

Trait Implementations§

source§

impl Clone for Class

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Class

source§

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

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

impl PartialEq for Class

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Send for Class

source§

impl Sync for Class

Auto Trait Implementations§

§

impl !Freeze for Class

§

impl !RefUnwindSafe for Class

§

impl Unpin for Class

§

impl UnwindSafe for Class

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.