pub struct Project<S, T, E>{ /* private fields */ }
Expand description
Projects the tuples of an inner sub-expression of type S
to tuples of type T
.
Example:
use codd::{Database, expression::Project};
let mut db = Database::new();
let fruit = db.add_relation::<String>("R").unwrap();
db.insert(&fruit, vec!["Apple".to_string(), "BANANA".to_string(), "cherry".to_string()].into());
let lower = Project::new(
&fruit,
|t| t.to_lowercase(), // projecting closure
);
assert_eq!(vec!["apple", "banana", "cherry"], db.evaluate(&lower).unwrap().into_tuples());
Implementations§
Source§impl<S, T, E> Project<S, T, E>
impl<S, T, E> Project<S, T, E>
Sourcepub fn new<I>(expression: I, mapper: impl FnMut(&S) -> T + 'static) -> Selfwhere
I: IntoExpression<S, E>,
pub fn new<I>(expression: I, mapper: impl FnMut(&S) -> T + 'static) -> Selfwhere
I: IntoExpression<S, E>,
Creates a new Project
expression over expression
with a closure mapper
that
projects tuples of expression
to the resulting tuples.
Sourcepub fn expression(&self) -> &E
pub fn expression(&self) -> &E
Returns a reference to the underlying sub-expression.
Trait Implementations§
Source§impl<S, T, E> Expression<T> for Project<S, T, E>
impl<S, T, E> Expression<T> for Project<S, T, E>
Auto Trait Implementations§
impl<S, T, E> Freeze for Project<S, T, E>where
E: Freeze,
impl<S, T, E> !RefUnwindSafe for Project<S, T, E>
impl<S, T, E> !Send for Project<S, T, E>
impl<S, T, E> !Sync for Project<S, T, E>
impl<S, T, E> Unpin for Project<S, T, E>where
E: Unpin,
impl<S, T, E> !UnwindSafe for Project<S, T, E>
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, E> IntoExpression<T, E> for Ewhere
T: Tuple,
E: Expression<T>,
impl<T, E> IntoExpression<T, E> for Ewhere
T: Tuple,
E: Expression<T>,
Source§fn into_expression(self) -> E
fn into_expression(self) -> E
Consumes the receiver and returns an expression.