Skip to content

Commit 9d49594

Browse files
author
Terence
committed
Add type annotations to table tests
1 parent 8ca286f commit 9d49594

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

hlua/src/rust_tables.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,9 @@ mod tests {
371371

372372
lua.set("v", &orig[..]);
373373

374-
let read: Vec<_> = lua.get("v").unwrap();
374+
let read: Vec<f64> = lua.get("v").unwrap();
375375
for (o, r) in orig.iter().zip(read.iter()) {
376-
if let AnyLuaValue::LuaNumber(ref n) = *r {
377-
assert_eq!(o, n);
378-
} else {
379-
panic!("Unexpected variant");
380-
}
376+
assert_eq!(*o, *r);
381377
}
382378
}
383379

@@ -387,7 +383,7 @@ mod tests {
387383

388384
lua.execute::<()>(r#"v = { [-1] = -1, [2] = 2, [42] = 42 }"#).unwrap();
389385

390-
let read: Option<Vec<_>> = lua.get("v");
386+
let read: Option<Vec<AnyLuaValue>> = lua.get("v");
391387
if read.is_some() {
392388
panic!("Unexpected success");
393389
}
@@ -399,7 +395,7 @@ mod tests {
399395

400396
lua.execute::<()>(r#"v = { }"#).unwrap();
401397

402-
let read: Vec<_> = lua.get("v").unwrap();
398+
let read: Vec<f64> = lua.get("v").unwrap();
403399
assert_eq!(read.len(), 0);
404400
}
405401

@@ -409,7 +405,7 @@ mod tests {
409405

410406
lua.execute::<()>(r#"v = { [-1] = -1, ["foo"] = 2, [{}] = 42 }"#).unwrap();
411407

412-
let read: Option<Vec<_>> = lua.get("v");
408+
let read: Option<Vec<AnyLuaValue>> = lua.get("v");
413409
if read.is_some() {
414410
panic!("Unexpected success");
415411
}
@@ -429,7 +425,7 @@ mod tests {
429425

430426
lua.set("v", &orig[..]);
431427

432-
let read: Vec<_> = lua.get("v").unwrap();
428+
let read: Vec<AnyLuaValue> = lua.get("v").unwrap();
433429
assert_eq!(read, orig);
434430
}
435431

@@ -439,11 +435,11 @@ mod tests {
439435

440436
lua.execute::<()>(r#"v = { 1, 2, 3 }"#).unwrap();
441437

442-
let read: Vec<_> = lua.get("v").unwrap();
438+
let read: Vec<AnyLuaValue> = lua.get("v").unwrap();
443439
assert_eq!(
444440
read,
445441
[1., 2., 3.].iter()
446-
.map(|x| AnyLuaValue::LuaNumber(*x)).collect::<Vec<_>>());
442+
.map(|x| AnyLuaValue::LuaNumber(*x)).collect::<Vec<AnyLuaValue>>());
447443
}
448444

449445
#[test]

0 commit comments

Comments
 (0)