Returns the set of names that appear more than once.
(names: &[String])
| 519 | |
| 520 | /// Returns the set of names that appear more than once. |
| 521 | pub fn duplicate_fields(names: &[String]) -> HashSet<String> { |
| 522 | let mut seen = HashMap::new(); |
| 523 | for n in names { |
| 524 | *seen.entry(n.clone()).or_insert(0) += 1; |
| 525 | } |
| 526 | seen.into_iter() |
| 527 | .filter(|(_, count)| *count > 1) |
| 528 | .map(|(name, _)| name) |
| 529 | .collect() |
| 530 | } |
| 531 | |
| 532 | /// Row type with these fields (nullable = false for table row). |
| 533 | pub fn row_type(&self) -> RowType { |