Skip to main content

promote_specs

Function promote_specs 

Source
pub const fn promote_specs(lhs: MemberSpec, rhs: MemberSpec) -> MemberSpec
Expand description

Combine two member facts under the ordinary numeric promotion rules.

A boolean yields to anything. Two members of one kind keep the higher level. An integer with a float or complex yields to that kind’s widest member, because an integer is widened rather than mixed. A float with a complex takes the narrowest complex that can still hold both, which keeps f32 + c32 in c32 while f64 + c32 becomes c64.

§Examples

use tenferro_tensor_core::{promote_specs, MemberKind, MemberSpec};

let f32_ = MemberSpec::new(MemberKind::Float, 0, 32);
let c32 = MemberSpec::new(MemberKind::Complex, 0, 32);
assert_eq!(promote_specs(f32_, c32), c32);