FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remove wrong Deref by youknowone · Pull Request #6620 · RustPython/RustPython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rs  (13) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 2 additions & 2 deletions crates/stdlib/src/array.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,11 @@ mod array {
}

fn f32_try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<f32> {
ArgIntoFloat::try_from_object(vm, obj).map(|x| *x as f32)
ArgIntoFloat::try_from_object(vm, obj).map(|x| x.into_float() as f32)
}

fn f64_try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<f64> {
ArgIntoFloat::try_from_object(vm, obj).map(Into::into)
ArgIntoFloat::try_from_object(vm, obj).map(|x| x.into_float())
}

fn pyfloat_from_f32(value: f32) -> PyFloat {
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/src/bisect.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod _bisect {
#[inline]
fn handle_default(arg: OptionalArg<ArgIndex>, vm: &VirtualMachine) -> PyResult<Option<isize>> {
arg.into_option()
.map(|v| v.try_to_primitive(vm))
.map(|v| v.into_int_ref().try_to_primitive(vm))
.transpose()
}

Expand Down
54 changes: 27 additions & 27 deletions crates/stdlib/src/cmath.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,64 @@ mod cmath {

#[pyfunction]
fn phase(z: ArgIntoComplex) -> f64 {
z.arg()
z.into_complex().arg()
}

#[pyfunction]
fn polar(x: ArgIntoComplex) -> (f64, f64) {
x.to_polar()
x.into_complex().to_polar()
}

#[pyfunction]
fn rect(r: ArgIntoFloat, phi: ArgIntoFloat) -> Complex64 {
Complex64::from_polar(*r, *phi)
Complex64::from_polar(r.into_float(), phi.into_float())
}

#[pyfunction]
fn isinf(z: ArgIntoComplex) -> bool {
let Complex64 { re, im } = *z;
let Complex64 { re, im } = z.into_complex();
re.is_infinite() || im.is_infinite()
}

#[pyfunction]
fn isfinite(z: ArgIntoComplex) -> bool {
z.is_finite()
z.into_complex().is_finite()
}

#[pyfunction]
fn isnan(z: ArgIntoComplex) -> bool {
z.is_nan()
z.into_complex().is_nan()
}

#[pyfunction]
fn exp(z: ArgIntoComplex, vm: &VirtualMachine) -> PyResult<Complex64> {
let z = *z;
let z = z.into_complex();
result_or_overflow(z, z.exp(), vm)
}

#[pyfunction]
fn sqrt(z: ArgIntoComplex) -> Complex64 {
z.sqrt()
z.into_complex().sqrt()
}

#[pyfunction]
fn sin(z: ArgIntoComplex) -> Complex64 {
z.sin()
z.into_complex().sin()
}

#[pyfunction]
fn asin(z: ArgIntoComplex) -> Complex64 {
z.asin()
z.into_complex().asin()
}

#[pyfunction]
fn cos(z: ArgIntoComplex) -> Complex64 {
z.cos()
z.into_complex().cos()
}

#[pyfunction]
fn acos(z: ArgIntoComplex) -> Complex64 {
z.acos()
z.into_complex().acos()
}

#[pyfunction]
Expand All @@ -90,56 +90,56 @@ mod cmath {
// which returns NaN when base is negative.
// log10(z) / log10(base) yields correct results but division
// doesn't handle pos/neg zero nicely. (i.e log(1, 0.5))
z.log(
z.into_complex().log(
base.into_option()
.map(|base| base.re)
.map(|base| base.into_complex().re)
.unwrap_or(core::f64::consts::E),
)
}

#[pyfunction]
fn log10(z: ArgIntoComplex) -> Complex64 {
z.log(10.0)
z.into_complex().log(10.0)
}

#[pyfunction]
fn acosh(z: ArgIntoComplex) -> Complex64 {
z.acosh()
z.into_complex().acosh()
}

#[pyfunction]
fn atan(z: ArgIntoComplex) -> Complex64 {
z.atan()
z.into_complex().atan()
}

#[pyfunction]
fn atanh(z: ArgIntoComplex) -> Complex64 {
z.atanh()
z.into_complex().atanh()
}

#[pyfunction]
fn tan(z: ArgIntoComplex) -> Complex64 {
z.tan()
z.into_complex().tan()
}

#[pyfunction]
fn tanh(z: ArgIntoComplex) -> Complex64 {
z.tanh()
z.into_complex().tanh()
}

#[pyfunction]
fn sinh(z: ArgIntoComplex) -> Complex64 {
z.sinh()
z.into_complex().sinh()
}

#[pyfunction]
fn cosh(z: ArgIntoComplex) -> Complex64 {
z.cosh()
z.into_complex().cosh()
}

#[pyfunction]
fn asinh(z: ArgIntoComplex) -> Complex64 {
z.asinh()
z.into_complex().asinh()
}

#[derive(FromArgs)]
Expand All @@ -156,10 +156,10 @@ mod cmath {

#[pyfunction]
fn isclose(args: IsCloseArgs, vm: &VirtualMachine) -> PyResult<bool> {
let a = *args.a;
let b = *args.b;
let rel_tol = args.rel_tol.map_or(1e-09, Into::into);
let abs_tol = args.abs_tol.map_or(0.0, Into::into);
let a = args.a.into_complex();
let b = args.b.into_complex();
let rel_tol = args.rel_tol.map_or(1e-09, |v| v.into_float());
let abs_tol = args.abs_tol.map_or(0.0, |v| v.into_float());

if rel_tol < 0.0 || abs_tol < 0.0 {
return Err(vm.new_value_error("tolerances must be non-negative"));
Expand Down
Loading
Loading

Back | FazBrowse Home | New Git URL