Skip to content

Commit 2fc3ad6

Browse files
committed
Polish ex_data variable initialization
1 parent a17ddcc commit 2fc3ad6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

qlog/src/testing/event_tests.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,10 @@ fn packet_header() {
173173
#[test]
174174
fn metrics_updated_with_ex_data() {
175175
// Test that ex_data fields are flattened into the same object
176-
let mut ex_data = ExData::new();
177-
ex_data.insert(
176+
let mut ex_data = ExData::from([(
178177
"delivery_rate".to_string(),
179178
serde_json::json!(DELIVERY_RATE),
180-
);
179+
)]);
181180

182181
let metrics = MetricsUpdated {
183182
min_rtt: Some(MIN_RTT),
@@ -202,8 +201,11 @@ fn metrics_updated_ex_data_collision() {
202201
// Test collision: same field set via struct AND ex_data.
203202
// With serde's preserve_order feature and ex_data at the top of the
204203
// struct, standard fields are serialized last and take precedence.
205-
let mut ex_data = ExData::new();
206-
ex_data.insert("min_rtt".to_string(), serde_json::json!(COLLISION_VALUE));
204+
205+
let mut ex_data = ExData::from([(
206+
"min_rtt".to_string(),
207+
serde_json::json!(COLLISION_VALUE),
208+
)]);
207209

208210
let metrics = MetricsUpdated {
209211
min_rtt: Some(MIN_RTT), // struct field value
@@ -221,11 +223,10 @@ fn metrics_updated_ex_data_collision() {
221223
#[test]
222224
fn metrics_updated_round_trip() {
223225
// Test serialization -> deserialization round-trip
224-
let mut ex_data = ExData::new();
225-
ex_data.insert(
226+
let ex_data = ExData::from([(
226227
"delivery_rate".to_string(),
227228
serde_json::json!(DELIVERY_RATE),
228-
);
229+
)]);
229230

230231
let original = MetricsUpdated {
231232
min_rtt: Some(MIN_RTT),

0 commit comments

Comments
 (0)