Skip to main content

rename/
rename.rs

1//! Demonstrates how to rename attributes with the `RENAME` operation.
2
3use darwen::prelude::{AttributeName, Relation, RelationBuilder, ScalarType};
4use darwen::{heading, tuple};
5
6fn contacts() -> Relation {
7    RelationBuilder::new()
8        .with_heading(heading!(name = ScalarType::String, phone = ScalarType::String).unwrap())
9        .with_body(vec![
10            tuple!(name = "Rita", phone = "212-85-06").unwrap(),
11            tuple!(name = "Tina", phone = "212-85-06").unwrap(),
12            tuple!(name = "Sandra", phone = "212-85-06").unwrap(),
13        ])
14        .build()
15        .unwrap()
16}
17
18fn main() {
19    let contacts = contacts();
20
21    println!(
22        "{}",
23        contacts
24            .rename(&[(
25                AttributeName::from("phone"),
26                AttributeName::from("red_phone")
27            )])
28            .unwrap()
29    );
30}