pub enum Patch<T> {
Ignore,
Update(T),
}Expand description
Represents a potential update to a value, either providing a new value or explicitly indicating that the value should be ignored/unchanged.
This is useful in PATCH-style updates where some fields should be updated while others
remain unchanged. Unlike Option, Patch makes the intent to ignore a value explicit.
Variants§
Ignore
Explicitly indicates that the existing value should remain unchanged
Update(T)
Contains a value that should replace the existing value
Implementations§
Source§impl<T> Patch<T>
impl<T> Patch<T>
Sourcepub const fn update(value: T) -> Self
pub const fn update(value: T) -> Self
Creates a new Patch variant that will update to the given value
Sourcepub const fn ignore() -> Self
pub const fn ignore() -> Self
Creates a new Patch::Ignore variant indicating no update should occur
pub const fn is_ignore(&self) -> bool
Sourcepub const fn as_ref(&self) -> Patch<&T>
pub const fn as_ref(&self) -> Patch<&T>
Returns a new Patch that references the inner value without taking ownership
Sourcepub const fn as_option_ref(&self) -> Option<&T>
pub const fn as_option_ref(&self) -> Option<&T>
Converts the Patch into an Option that borrows the inner value
Sourcepub fn as_option(&self) -> Option<T>where
T: Clone,
pub fn as_option(&self) -> Option<T>where
T: Clone,
Converts the Patch into an Option containing a clone of the inner value
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Converts the Patch into an Option, consuming self