Skip to main content

require_angular_pair

Function require_angular_pair 

Source
pub fn require_angular_pair(
    a_flag: &'static str,
    a: Option<f64>,
    b_flag: &'static str,
    b: Option<f64>,
) -> Result<Option<(f64, f64)>, String>
Expand description

Assembles an all-or-nothing pair of angular profile fields — OpticProfile’s TravelLimits/TurretState axes — from two independently-Option values (MBA-1348). None only when NEITHER is set; Some only when BOTH are; a named-field Err when exactly one is. A silently-defaulted 0.0 for the missing half would assert a specific, likely-false physical fact (e.g. “zero down travel from zero”) rather than “not recorded” — exactly the silent fabrication OpticProfile’s own doc comments warn against — so an incomplete pair is rejected by name instead of guessed at.

a_flag/b_flag name the CLI FLAGS (e.g. "--travel-up"), not the internal ProfileData struct fields (MBA-1348 review fix I2): the field↔flag mapping is not mechanical (--travel-up drops the axis prefix elevation_travel_up_mil carries; --turret-elev abbreviates turret_elevation_dialed_mil), and a user who typed --travel-up has no reason to recognize elevation_travel_up_mil in an error. This matches the convention two call sites above already use ("--elevation-click '{v}' is invalid").