Skip to content

Commit 8c0acce

Browse files
committed
add a comment explaining how merging works
1 parent 6e36207 commit 8c0acce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/merge.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ use indexmap::IndexMap;
33

44
use crate::parser_util::alias_or_name;
55

6+
/// Merges duplicates in a vector of fields. The fields in the vector are added to a
7+
/// map from field name to field. If a field with the same name already exists in the
8+
/// map, the existing and new fields' children are combined into the existing field's
9+
/// children. These children will be merged later when they are normalized.
10+
///
11+
/// The map is an `IndexMap` to ensure iteration order of the fields is preserved.
12+
/// This prevents tests from being flaky due to field order changing between test runs.
613
pub fn merge<'a, 'b, T>(fields: Vec<Field<'a, T>>) -> Result<Vec<Field<'a, T>>, String>
714
where
815
T: Text<'a> + Eq + AsRef<str>,

0 commit comments

Comments
 (0)