pub enum MutatorResult {
Value(Value),
Skip,
}Expand description
修改器返回结果 — 对齐 PHP setXxxAttr 返回值语义
PHP setXxxAttr($value, $data) 返回值的三种情况:
- 返回非 null 值 → 写入
$this->data[$name] - 返回 null 且未修改
$this->data→ 写入 null - 返回 null 且已修改
$this->data→ 提前返回,不写入当前字段
Rust 中用 MutatorResult 显式表达:
Value(v):对应情况 1Skip:对应情况 3(修改器内部已通过data_map_mut修改 data)
情况 2 在 Rust 中通过 Some(MutatorResult::Value(Value::Null)) 表达。
Variants§
Value(Value)
修改器返回具体值,写入 $this->data[$name]
Skip
修改器返回 null 且内部已修改 data,跳过默认赋值
(对应 PHP Attribute.php 第 379-381 行提前返回分支)
Trait Implementations§
Source§impl Clone for MutatorResult
impl Clone for MutatorResult
Source§fn clone(&self) -> MutatorResult
fn clone(&self) -> MutatorResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MutatorResult
impl Debug for MutatorResult
Source§impl PartialEq for MutatorResult
impl PartialEq for MutatorResult
impl StructuralPartialEq for MutatorResult
Auto Trait Implementations§
impl Freeze for MutatorResult
impl RefUnwindSafe for MutatorResult
impl Send for MutatorResult
impl Sync for MutatorResult
impl Unpin for MutatorResult
impl UnsafeUnpin for MutatorResult
impl UnwindSafe for MutatorResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more