pub struct RecordPattern<'ast> {
pub patterns: &'ast [FieldPattern<'ast>],
pub tail: TailPattern,
pub pos: TermPos,
}Expand description
A record pattern.
Fields§
§patterns: &'ast [FieldPattern<'ast>]The patterns for each field in the record.
tail: TailPatternThe tail of the pattern, indicating if the pattern is open, i.e. if it ended with an ellipsis, capturing the rest or not.
pos: TermPosImplementations§
Source§impl RecordPattern<'_>
impl RecordPattern<'_>
Sourcepub fn check_dup(&self) -> Result<(), ParseError>
pub fn check_dup(&self) -> Result<(), ParseError>
Check the matches for duplication, and raise an error if any occurs.
Note that for backwards-compatibility reasons this function only checks top-level matches. In Nickel 1.0, this code panicked:
let f = fun { x, x, .. } => x in f { x = 1 }However this “works”, even though the binding to y is duplicated.
let f =
fun { x = { y }, z = { y }, .. } => y
in f { x = { y = 1 }, z = { y = 2 } }
# evaluates to 1This function aims to raise errors in the first case, but maintain the behaviour in the second case.
Trait Implementations§
Source§impl<'ast> Clone for RecordPattern<'ast>
impl<'ast> Clone for RecordPattern<'ast>
Source§fn clone(&self) -> RecordPattern<'ast>
fn clone(&self) -> RecordPattern<'ast>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CloneTo for RecordPattern<'_>
impl CloneTo for RecordPattern<'_>
Source§type Data<'ast> = RecordPattern<'ast>
type Data<'ast> = RecordPattern<'ast>
This is always
Self, be we need associated types to make Rust understand that Self is
always parametric over the 'ast lifetime. We’re using GATs to emulate higher-kinded
types.Source§impl<'ast> Debug for RecordPattern<'ast>
impl<'ast> Debug for RecordPattern<'ast>
Source§impl Display for RecordPattern<'_>
impl Display for RecordPattern<'_>
Source§impl<'ast> PartialEq for RecordPattern<'ast>
impl<'ast> PartialEq for RecordPattern<'ast>
Source§impl<'a> Pretty<'a, Allocator> for &RecordPattern<'_>
impl<'a> Pretty<'a, Allocator> for &RecordPattern<'_>
impl Allocable for RecordPattern<'_>
impl<'ast> Eq for RecordPattern<'ast>
impl<'ast> StructuralPartialEq for RecordPattern<'ast>
Auto Trait Implementations§
impl<'ast> Freeze for RecordPattern<'ast>
impl<'ast> RefUnwindSafe for RecordPattern<'ast>
impl<'ast> Send for RecordPattern<'ast>
impl<'ast> Sync for RecordPattern<'ast>
impl<'ast> Unpin for RecordPattern<'ast>
impl<'ast> UnsafeUnpin for RecordPattern<'ast>
impl<'ast> UnwindSafe for RecordPattern<'ast>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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