Result<T, E>.from constructor

Result<T, E>.from(
  1. T? value,
  2. E err
)

Creates a Result from the given nullable T value.

Creates:

  • Ok using the given T value if the given T value is not null.
  • Err using the given E value if the given T value is null.

Implementation

factory Result.from(T? value, E err) => switch (value) {
	null => Err(err),
	_ => Ok(value)
};