Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Documentation of the Changes Implemented
This update focuses on improving the typing and behavior of the
Result
class, especially in failure (Fail
) cases. Changes were made to explicitly set the generic type of the value (T
) in failures tonull
, and new methods were introduced to simplify validations and make the code safer and more readable.Main Changes
1. Typing Change in Failures
T
inFail
is now explicitly set tonull
:Result
(value()
) will always benull
.2. Introduction of the
isNull
Method#data
) of aResult
isnull
:null
values from success and failure states.3. Adjustments to Creation Methods and Adapters
create
) and adapters now explicitly returnResult<T | null, ...>
:Example: Using
Result
After the ChangesCreating a Failure Result
Handling Possible Failures in a Factory
Example: Adapters Returning
null
Conversion Adapter
Summary of Improvements
Explicit Typing in Failures:
T
) is alwaysnull
in failure states, improving type safety.New
isNull
Method:Consistency in Creation Methods:
Result<T | null>
where applicable.Safer and More Readable Code:
Version Release
This fix will be published in a beta version for testing:
1.23.5.beta-0
.#194