Struct OnionLazySet

Source
pub struct OnionLazySet { /* private fields */ }
Expand description

Onion 惰性集合。

封装一个容器对象和一个过滤器对象,支持基于过滤器的惰性筛选。 适用于大规模数据的延迟求值与高效遍历。

§字段

  • container: 集合的底层容器对象(如元组、数组等)
  • filter: 用于筛选元素的过滤器对象(如 Lambda 表达式)

Implementations§

Source§

impl OnionLazySet

Source

pub fn new(container: OnionObject, filter: OnionObject) -> Self

创建新的惰性集合。

§参数
  • container: 底层容器对象
  • filter: 过滤器对象
§返回

新的惰性集合实例

Source

pub fn new_static( container: &OnionStaticObject, filter: &OnionStaticObject, ) -> OnionStaticObject

创建静态惰性集合对象。

§参数
  • container: 静态容器对象
  • filter: 静态过滤器对象
§返回

稳定化后的静态惰性集合对象

Source

pub fn get_container(&self) -> &OnionObject

获取底层容器对象的引用。

Source

pub fn get_filter(&self) -> &OnionObject

获取过滤器对象的引用。

Source

pub fn upgrade(&self, collected: &mut Vec<GCArc<OnionObjectCell>>)

升级集合中的所有对象引用。

用于 GC 跟踪,防止集合中的对象被提前回收。

Source

pub fn with_attribute<F, R>( &self, key: &OnionObject, f: &F, ) -> Result<R, RuntimeError>
where F: Fn(&OnionObject) -> Result<R, RuntimeError>,

按属性名访问集合的内部成员或操作。

支持访问 “container”、“filter”、“collect” 三个属性:

  • container: 返回底层容器对象
  • filter: 返回过滤器对象
  • collect: 返回惰性收集器 Lambda
§参数
  • key: 属性名对象
  • f: 处理函数,对应属性对象作为参数
§返回
  • Ok(R): 访问成功,返回处理函数结果
  • Err(RuntimeError): 属性不存在或访问失败

Trait Implementations§

Source§

impl Debug for OnionLazySet

Source§

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

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

impl GCTraceable<OnionObjectCell> for OnionLazySet

Source§

fn collect(&self, queue: &mut VecDeque<GCArcWeak<OnionObjectCell>>)

collects all reachable objects and adds them to the provided queue.

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

Source§

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

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.