checked_add

Function checked_add 

Source
pub fn checked_add(
    lhs: impl Into<String>,
    rhs: impl Into<String>,
) -> Result<String, &'static str>
Expand description

Perform checked_add on floating points. Inherits the “checked_add” property of rust in integers. When failed, it’ll return Err(message). Success, Ok(value).

NOTE: Must use basic numbers UTF-8 or it’ll fail.

Example:

let lhs = "172.28";
let rhs = "192.168";
 
assert_eq!(string_calc::checked_add(lhs, rhs).unwrap(), 
  "364.448".to_owned());