pub fn ensure_shape(ok: bool, msg: impl FnOnce() -> String) -> Result<()>Expand description
Return Error::Shape with the message of msg unless ok (inconsistent lengths
or shapes; ensure for a parameter outside its domain).
§Errors
Error::Shape when ok is false.
§Examples
use comnum_core::{ensure_shape, Error};
let err = ensure_shape(false, || "3 rows for a code of 2 outputs".into()).unwrap_err();
assert!(matches!(err, Error::Shape(_)));
assert_eq!(err.to_string(), "inconsistent shapes: 3 rows for a code of 2 outputs");