testResult<T> function
Calls test(result) and returns result as is if test return true. Otherwise returns Err(ArgumentError(failedTestMsg)).
Implementation
Result<T> testResult<T>(bool Function(Result<T>) test, Result<T> result,
String failedTestMsg) =>
test(result) ? result : Err(ArgumentError(failedTestMsg));