Fix annoying inference errors
This commit is contained in:
parent
171b38a0a1
commit
56c218f70e
|
@ -135,7 +135,7 @@ fn ascii() {
|
||||||
// _PyUnicode_NONCOMPACT_DATA isn't valid for compact strings.
|
// _PyUnicode_NONCOMPACT_DATA isn't valid for compact strings.
|
||||||
assert!(!PyUnicode_DATA(ptr).is_null());
|
assert!(!PyUnicode_DATA(ptr).is_null());
|
||||||
|
|
||||||
assert_eq!(PyUnicode_GET_LENGTH(ptr), s.len().unwrap() as _);
|
assert_eq!(PyUnicode_GET_LENGTH(ptr), s.len().unwrap() as Py_ssize_t);
|
||||||
assert_eq!(PyUnicode_IS_READY(ptr), 1);
|
assert_eq!(PyUnicode_IS_READY(ptr), 1);
|
||||||
|
|
||||||
// This has potential to mutate object. But it should be a no-op since
|
// This has potential to mutate object. But it should be a no-op since
|
||||||
|
@ -175,7 +175,10 @@ fn ucs4() {
|
||||||
// _PyUnicode_NONCOMPACT_DATA isn't valid for compact strings.
|
// _PyUnicode_NONCOMPACT_DATA isn't valid for compact strings.
|
||||||
assert!(!PyUnicode_DATA(ptr).is_null());
|
assert!(!PyUnicode_DATA(ptr).is_null());
|
||||||
|
|
||||||
assert_eq!(PyUnicode_GET_LENGTH(ptr), py_string.len().unwrap() as _);
|
assert_eq!(
|
||||||
|
PyUnicode_GET_LENGTH(ptr),
|
||||||
|
py_string.len().unwrap() as Py_ssize_t
|
||||||
|
);
|
||||||
assert_eq!(PyUnicode_IS_READY(ptr), 1);
|
assert_eq!(PyUnicode_IS_READY(ptr), 1);
|
||||||
|
|
||||||
// This has potential to mutate object. But it should be a no-op since
|
// This has potential to mutate object. But it should be a no-op since
|
||||||
|
|
|
@ -120,8 +120,14 @@ mod tests {
|
||||||
let obj = vec![10, 20].to_object(py);
|
let obj = vec![10, 20].to_object(py);
|
||||||
let inst = obj.as_ref(py);
|
let inst = obj.as_ref(py);
|
||||||
let mut it = inst.iter().unwrap();
|
let mut it = inst.iter().unwrap();
|
||||||
assert_eq!(10, it.next().unwrap().unwrap().extract().unwrap());
|
assert_eq!(
|
||||||
assert_eq!(20, it.next().unwrap().unwrap().extract().unwrap());
|
10_i32,
|
||||||
|
it.next().unwrap().unwrap().extract::<'_, i32>().unwrap()
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
20_i32,
|
||||||
|
it.next().unwrap().unwrap().extract::<'_, i32>().unwrap()
|
||||||
|
);
|
||||||
assert!(it.next().is_none());
|
assert!(it.next().is_none());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -138,7 +144,10 @@ mod tests {
|
||||||
let inst = obj.as_ref(py);
|
let inst = obj.as_ref(py);
|
||||||
let mut it = inst.iter().unwrap();
|
let mut it = inst.iter().unwrap();
|
||||||
|
|
||||||
assert_eq!(10, it.next().unwrap().unwrap().extract().unwrap());
|
assert_eq!(
|
||||||
|
10_i32,
|
||||||
|
it.next().unwrap().unwrap().extract::<'_, i32>().unwrap()
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
|
@ -167,7 +176,10 @@ mod tests {
|
||||||
let inst = obj.as_ref(py);
|
let inst = obj.as_ref(py);
|
||||||
let mut it = inst.iter().unwrap();
|
let mut it = inst.iter().unwrap();
|
||||||
|
|
||||||
assert_eq!(10, it.next().unwrap().unwrap().extract().unwrap());
|
assert_eq!(
|
||||||
|
10_i32,
|
||||||
|
it.next().unwrap().unwrap().extract::<'_, i32>().unwrap()
|
||||||
|
);
|
||||||
assert!(it.next().unwrap().unwrap().is_none());
|
assert!(it.next().unwrap().unwrap().is_none());
|
||||||
}
|
}
|
||||||
assert_eq!(count, none.get_refcnt(py));
|
assert_eq!(count, none.get_refcnt(py));
|
||||||
|
|
|
@ -407,12 +407,12 @@ mod tests {
|
||||||
|
|
||||||
// iter method
|
// iter method
|
||||||
for el in set.iter() {
|
for el in set.iter() {
|
||||||
assert_eq!(1i32, el.extract().unwrap());
|
assert_eq!(1i32, el.extract::<'_, i32>().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// intoiterator iteration
|
// intoiterator iteration
|
||||||
for el in set {
|
for el in set {
|
||||||
assert_eq!(1i32, el.extract().unwrap());
|
assert_eq!(1i32, el.extract::<'_, i32>().unwrap());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,13 +508,13 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(iter.size_hint(), (3, Some(3)));
|
assert_eq!(iter.size_hint(), (3, Some(3)));
|
||||||
|
|
||||||
assert_eq!(1, iter.next().unwrap().extract().unwrap());
|
assert_eq!(1_i32, iter.next().unwrap().extract::<'_, i32>().unwrap());
|
||||||
assert_eq!(iter.size_hint(), (2, Some(2)));
|
assert_eq!(iter.size_hint(), (2, Some(2)));
|
||||||
|
|
||||||
assert_eq!(2, iter.next().unwrap().extract().unwrap());
|
assert_eq!(2_i32, iter.next().unwrap().extract::<'_, i32>().unwrap());
|
||||||
assert_eq!(iter.size_hint(), (1, Some(1)));
|
assert_eq!(iter.size_hint(), (1, Some(1)));
|
||||||
|
|
||||||
assert_eq!(3, iter.next().unwrap().extract().unwrap());
|
assert_eq!(3_i32, iter.next().unwrap().extract::<'_, i32>().unwrap());
|
||||||
assert_eq!(iter.size_hint(), (0, Some(0)));
|
assert_eq!(iter.size_hint(), (0, Some(0)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ mod tests {
|
||||||
assert_eq!(3, tuple.len());
|
assert_eq!(3, tuple.len());
|
||||||
|
|
||||||
for (i, item) in tuple.iter().enumerate() {
|
for (i, item) in tuple.iter().enumerate() {
|
||||||
assert_eq!(i + 1, item.extract().unwrap());
|
assert_eq!(i + 1, item.extract::<'_, usize>().unwrap());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -541,9 +541,9 @@ mod tests {
|
||||||
|
|
||||||
let slice = tuple.as_slice();
|
let slice = tuple.as_slice();
|
||||||
assert_eq!(3, slice.len());
|
assert_eq!(3, slice.len());
|
||||||
assert_eq!(1, slice[0].extract().unwrap());
|
assert_eq!(1_i32, slice[0].extract::<'_, i32>().unwrap());
|
||||||
assert_eq!(2, slice[1].extract().unwrap());
|
assert_eq!(2_i32, slice[1].extract::<'_, i32>().unwrap());
|
||||||
assert_eq!(3, slice[2].extract().unwrap());
|
assert_eq!(3_i32, slice[2].extract::<'_, i32>().unwrap());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue