Struct Assignments
pub struct Assignments { /* private fields */ }Expand description
An ordered map of field assignments for an Update statement.
Each entry maps a field projection (identifying which field to change) to an
Assignment (how to change it). The entries are ordered by projection,
allowing range queries over prefixes.
§Examples
use toasty_core::stmt::{Assignments, Expr, Projection};
let mut assignments = Assignments::default();
assert!(assignments.is_empty());
assignments.set(Projection::single(0), Expr::null());
assert_eq!(assignments.len(), 1);Implementations§
§impl Assignments
impl Assignments
pub fn new() -> Assignments
pub fn new() -> Assignments
Creates an empty Assignments.
pub fn contains<Q>(&self, key: &Q) -> bool
pub fn contains<Q>(&self, key: &Q) -> bool
Returns true if an assignment exists for the given projection.
The key accepts any type that implements AsRef<[usize]>:
Projection— look up by projection directly&[usize]— a slice of field indices (e.g.,&[1, 2])[usize; N]— a fixed-size array (e.g.,[1],[1, 2]). Integer literals infer asusizefrom theAsRef<[usize]>bound, so&[1]works without a suffix.
pub fn get<Q>(&self, key: &Q) -> Option<&Assignment>
pub fn get<Q>(&self, key: &Q) -> Option<&Assignment>
Returns a reference to the assignment for the given projection, if any.
The key accepts any type that implements AsRef<[usize]>:
Projection— look up by projection directly&[usize]— a slice of field indices (e.g.,&[1, 2])[usize; N]— a fixed-size array (e.g.,[1],[1, 2]). Integer literals infer asusizefrom theAsRef<[usize]>bound, so&[1]works without a suffix.
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Assignment>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Assignment>
Returns a mutable reference to the assignment for the given projection.
The key accepts any type that implements AsRef<[usize]>:
Projection— look up by projection directly&[usize]— a slice of field indices (e.g.,&[1, 2])[usize; N]— a fixed-size array (e.g.,[1],[1, 2]). Integer literals infer asusizefrom theAsRef<[usize]>bound, so&[1]works without a suffix.
pub fn set<Q>(&mut self, key: Q, expr: impl Into<Expr>)where
Q: Into<Projection>,
pub fn set<Q>(&mut self, key: Q, expr: impl Into<Expr>)where
Q: Into<Projection>,
Sets a field to the given expression value, replacing any existing assignment for that projection.
pub fn unset<Q>(&mut self, key: &Q)
pub fn unset<Q>(&mut self, key: &Q)
Removes the assignment for the given projection, if any.
The key accepts any type that implements AsRef<[usize]>:
Projection— look up by projection directly&[usize]— a slice of field indices (e.g.,&[1, 2])[usize; N]— a fixed-size array (e.g.,[1],[1, 2]). Integer literals infer asusizefrom theAsRef<[usize]>bound, so&[1]works without a suffix.
pub fn insert<Q>(&mut self, key: Q, expr: impl Into<Expr>)where
Q: Into<Projection>,
pub fn insert<Q>(&mut self, key: Q, expr: impl Into<Expr>)where
Q: Into<Projection>,
Insert a value into a set. The expression should evaluate to a single value that is inserted into the set.
pub fn remove<Q>(&mut self, key: Q, expr: impl Into<Expr>)where
Q: Into<Projection>,
pub fn remove<Q>(&mut self, key: Q, expr: impl Into<Expr>)where
Q: Into<Projection>,
Adds a Remove assignment for the given projection.
pub fn take<Q>(&mut self, key: &Q) -> Option<Assignment>
pub fn take<Q>(&mut self, key: &Q) -> Option<Assignment>
Removes and returns the assignment for the given projection.
The key accepts any type that implements AsRef<[usize]>:
Projection— look up by projection directly&[usize]— a slice of field indices (e.g.,&[1, 2])[usize; N]— a fixed-size array (e.g.,[1],[1, 2]). Integer literals infer asusizefrom theAsRef<[usize]>bound, so&[1]works without a suffix.
pub fn keys(&self) -> impl Iterator<Item = &Projection>
pub fn keys(&self) -> impl Iterator<Item = &Projection>
Returns an iterator over the assignment projections (keys).
pub fn iter(&self) -> impl Iterator<Item = (&Projection, &Assignment)>
pub fn iter(&self) -> impl Iterator<Item = (&Projection, &Assignment)>
Returns an iterator over (projection, assignment) pairs.
pub fn iter_mut(
&mut self,
) -> impl Iterator<Item = (&Projection, &mut Assignment)>
pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (&Projection, &mut Assignment)>
Returns a mutable iterator over (projection, assignment) pairs.
Trait Implementations§
§impl Clone for Assignments
impl Clone for Assignments
§fn clone(&self) -> Assignments
fn clone(&self) -> Assignments
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Assignments
impl Debug for Assignments
§impl Default for Assignments
impl Default for Assignments
§fn default() -> Assignments
fn default() -> Assignments
§impl<Q> Index<Q> for Assignments
Indexes into the assignments by projection. Panics if no assignment exists
for the given key.
impl<Q> Index<Q> for Assignments
Indexes into the assignments by projection. Panics if no assignment exists for the given key.
The index accepts any type that implements AsRef<[usize]>:
Projection, &[usize], or [usize; N] arrays.
§type Output = Assignment
type Output = Assignment
§impl<Q> IndexMut<Q> for Assignments
Mutably indexes into the assignments by projection. Panics if no assignment
exists for the given key.
impl<Q> IndexMut<Q> for Assignments
Mutably indexes into the assignments by projection. Panics if no assignment exists for the given key.
The index accepts any type that implements AsRef<[usize]>:
Projection, &[usize], or [usize; N] arrays.