pub struct CaseBuilder { /* private fields */ }Expand description
A CASE expression under construction — bob’s CaseChain.
use keelson_core::expr::{case, literal, quote, Chain, arg};
// (CASE WHEN ("id" = $1) THEN 'A' ELSE 'B' END)
let e = case()
.when(quote("id").eq(arg(1i32)), literal("A"))
.else_(literal("B"));end and else_ both apply the parenthesisation
rule, so the result is (CASE .. END) — self-delimiting, and safe to drop into
an operand slot or alias with
Chain::as_.
Implementations§
Source§impl CaseBuilder
impl CaseBuilder
Sourcepub fn new() -> CaseBuilder
pub fn new() -> CaseBuilder
An empty CASE. At least one when is required before it
can render.
Sourcepub fn when(self, condition: impl IntoExpr, then: impl IntoExpr) -> CaseBuilder
pub fn when(self, condition: impl IntoExpr, then: impl IntoExpr) -> CaseBuilder
Add a WHEN condition THEN result branch.
Trait Implementations§
Source§impl Clone for CaseBuilder
impl Clone for CaseBuilder
Source§fn clone(&self) -> CaseBuilder
fn clone(&self) -> CaseBuilder
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 CaseBuilder
impl Debug for CaseBuilder
Source§impl Default for CaseBuilder
impl Default for CaseBuilder
Source§fn default() -> CaseBuilder
fn default() -> CaseBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for CaseBuilder
impl !UnwindSafe for CaseBuilder
impl Freeze for CaseBuilder
impl Send for CaseBuilder
impl Sync for CaseBuilder
impl Unpin for CaseBuilder
impl UnsafeUnpin for CaseBuilder
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