Skip to main content

Mapping

Struct Mapping 

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

表示一次 map 操作的调度状态。

  • container:待映射的容器对象(通常为元组)
  • mapper:映射器函数对象(lambda 或其他)
  • collected:已收集的映射结果
  • current_index:当前处理到的元素索引

Implementations§

Source§

impl Mapping

Source

pub fn new(container: &OnionStaticObject, mapper: &OnionStaticObject) -> Self

创建一个新的 Mapping 实例。

§参数
  • container - 待映射的容器对象(通常为元组)
  • mapper - 映射器函数对象(lambda 或其他)
§返回值

返回新创建的 Mapping 实例,初始状态下未处理任何元素。

Trait Implementations§

Source§

impl Clone for Mapping

Source§

fn clone(&self) -> Mapping

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 Runnable for Mapping

Source§

fn receive( &mut self, step_result: &StepResult, _gc: &mut GC<OnionObjectCell>, ) -> Result<(), RuntimeError>

接收子任务的执行结果,并收集到结果列表。

§参数
  • step_result - 子任务的执行结果,期望为 StepResult::Return
  • _gc - 垃圾收集器引用(未使用)
§返回值
  • Ok(()) - 成功收集结果并推进索引
  • Err(RuntimeError) - 收到非预期结果类型
Source§

fn step(&mut self, _gc: &mut GC<OnionObjectCell>) -> StepResult

执行 map 操作的一个调度步骤。

  • 若当前元素存在,尝试用 mapper 处理之:
    • 若 mapper 是 lambda,则生成新 Runnable 进行调用
    • 若 mapper 为 false,跳过当前元素
    • 其他情况直接收集元素
  • 若所有元素处理完毕,返回收集到的新元组
§返回值
  • StepResult::NewRunnable - 需要调度新任务
  • StepResult::Continue - 继续下一个元素
  • StepResult::Return - 所有元素处理完毕,返回结果
  • StepResult::Error - 类型错误或其他异常
Source§

fn format_context(&self) -> String

格式化 map 调度器的当前上下文信息。

输出当前映射器、容器、进度和已收集结果数量,便于调试。

§返回值

返回格式化的多行字符串,展示 map 操作的状态。

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

Source§

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

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.