CResult<Value, Error>.from constructor

CResult<Value, Error>.from(
  1. dynamic value
)

Constructs a CResult from a dynamic value If the value is CResult it will return the value itself If the value is Value it will return COk If the value is Error it will return CErr

Implementation

factory CResult.from(dynamic value) {
  if (value is CResult<Value, Error>) {
    return value;
  } else if (value is Value) {
    return COk(value);
  } else if (value is Error) {
    return CErr(value);
  } else {
    throw UnimplementedError();
  }
}