Add ArgFloatLike.

This commit is contained in:
jfh
2021-10-07 12:34:30 +03:00
parent acfdf9ceaa
commit 856f77fb77
8 changed files with 97 additions and 93 deletions

View File

@@ -12,11 +12,13 @@ mod array {
};
use crate::vm::{
builtins::{
IntoPyFloat, PyByteArray, PyBytes, PyBytesRef, PyIntRef, PyList, PyListRef, PySliceRef,
PyStr, PyStrRef, PyTypeRef,
PyByteArray, PyBytes, PyBytesRef, PyIntRef, PyList, PyListRef, PySliceRef, PyStr,
PyStrRef, PyTypeRef,
},
class_or_notimplemented,
function::{ArgBytesLike, ArgIterable, IntoPyObject, IntoPyResult, OptionalArg},
function::{
ArgBytesLike, ArgFloatLike, ArgIterable, IntoPyObject, IntoPyResult, OptionalArg,
},
protocol::{
BufferInternal, BufferOptions, BufferResizeGuard, PyBuffer, PyIterReturn,
PyMappingMethods,
@@ -521,11 +523,11 @@ mod array {
}
fn f32_try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<f32> {
IntoPyFloat::try_from_object(vm, obj).map(|x| x.to_f64() as f32)
ArgFloatLike::try_from_object(vm, obj).map(|x| x.to_f64() as f32)
}
fn f64_try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<f64> {
IntoPyFloat::try_from_object(vm, obj).map(|x| x.to_f64())
ArgFloatLike::try_from_object(vm, obj).map(|x| x.to_f64())
}
impl ArrayElement for WideChar {