pub fn column_names_and_types(desc: RelationDesc) -> Vec<(ColumnName, ColumnType)> {
    // Invent names for columns that don't have a name.
    let mut columns: Vec<_> = desc.into_iter().collect();

    // Deduplicate names.
    let mut seen = HashSet::new();
    for (name, _ty) in &mut columns {
        let stem_len = name.as_str().len();
        let mut i = 1;
        while seen.contains(name) {
            name.as_mut_str().truncate(stem_len);
            if name.as_str().ends_with(|c: char| c.is_ascii_digit()) {
                name.as_mut_str().push('_');
            }
            name.as_mut_str().push_str(&i.to_string());
            i += 1;
        }
        seen.insert(name);
    }
    columns
}
/// Extracts deduplicated column names and types from a relation description.
Extracts deduplicated column names and types from a relation description.
Extracts deduplicated column names and types from a relation description .
pub fn column_names_and_types(desc: RelationDesc) -> Vec<(ColumnName, ColumnType)> {
    // Invent names for columns that don't have a name.
    let mut columns: Vec<_> = desc.into_iter().collect();
    // Deduplicate names.
    let mut seen = HashSet::new();
    for (name, _ty) in &mut columns {
        let stem_len = name.as_str().len();
        let mut i = 1;
        while seen.contains(name) {
            name.as_mut_str().truncate(stem_len);
            if name.as_str().ends_with(|c: char| c.is_ascii_digit()) {
                name.as_mut_str().push('_');
            }
            name.as_mut_str().push_str(&i.to_string());
            i += 1;
        }
        seen.insert(name);
    }
    columns
}
pub fn column_names_and_types ( desc : RelationDesc ) -> Vec < ( ColumnName , ColumnType ) > { // Invent names for columns that don't have a name. let mut columns : Vec < _ > = desc . into_iter ( ) . collect ( ) ; // Deduplicate names. let mut seen = HashSet :: new ( ) ; for ( name , _ty ) in & mut columns { let stem_len = name . as_str ( ) . len ( ) ; let mut i = 1 ; while seen . contains ( name ) { name . as_mut_str ( ) . truncate ( stem_len ) ; if name . as_str ( ) . ends_with ( | c : char | c . is_ascii_digit ( ) ) { name . as_mut_str ( ) . push ( '_' ) ; } name . as_mut_str ( ) . push_str ( & i . to_string ( ) ) ; i += 1 ; } seen . insert ( name ) ; } columns }
Extracts deduplicated column names and types from a relation description.
Extracts deduplicated column names and types from a relation description .
desc
RelationDesc
desc
RelationDesc