pub struct PatField {
pub key: String,
pub pat: Pat,
pub default: Option<Expr>,
}Expand description
A field in an object destructuring pattern.
Represents one entry in { key: pat = default }.
Fields§
§key: StringThe source property key (e.g. "b" in { b: c }).
pat: PatThe binding target pattern (e.g. Pat::Ident("c") in { b: c }).
default: Option<Expr>Optional default value (e.g. "foo" in { a = "foo" }).
Implementations§
Source§impl PatField
impl PatField
Sourcepub fn shorthand(key: impl Into<String>) -> Self
pub fn shorthand(key: impl Into<String>) -> Self
Create a shorthand field: { key } binds key to Pat::Ident(key).
Sourcepub fn renamed(key: impl Into<String>, name: impl Into<String>) -> Self
pub fn renamed(key: impl Into<String>, name: impl Into<String>) -> Self
Create a renamed field: { key: name }.
Sourcepub fn nested(key: impl Into<String>, pat: Pat) -> Self
pub fn nested(key: impl Into<String>, pat: Pat) -> Self
Create a field with a nested pattern: { key: pat }.
Sourcepub fn with_default(self, default: Expr) -> Self
pub fn with_default(self, default: Expr) -> Self
Attach a default value to this field.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PatField
impl<'de> Deserialize<'de> for PatField
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl StructureEq for PatField
impl StructureEq for PatField
Source§fn structure_eq(&self, other: &Self) -> bool
fn structure_eq(&self, other: &Self) -> bool
Compare two values for structural equality.
impl StructuralPartialEq for PatField
Auto Trait Implementations§
impl Freeze for PatField
impl RefUnwindSafe for PatField
impl Send for PatField
impl Sync for PatField
impl Unpin for PatField
impl UnsafeUnpin for PatField
impl UnwindSafe for PatField
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request