Result.ok() gone in 5.x
See original GitHub issueWe’re upgrading from 4.1.1 to 5.1.0 and one large change we needed to do in our codebase was to replace Result.ok()
with Result.ok(Unit)
or else we were getting:
Error: Tried to construct `Ok` with `null`. Maybe you want `Maybe.Nothing`?
Two things I’d like to ask:
- Why is this a runtime check instead of a compile time check? The
.d.ts
files containexport declare function ok<T, E>(): Result<Unit, E>;
so all our code typechecked, but it blows up in runtime. If this is not a function call users of the library should not make then I think ideally it shouldn’t typecheck. - Can we get this convenience method back? One of the nice things about true-myth is that
Result
,Maybe
, andUnit
types are nicely connected to each other and this was one of the nicenesses. On usingMaybe
instead ofResult
: I thinkMaybe<ErrorType>
is not as clear asResult<Unit, ErrorType>
in terms of what the code is doing.
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Converting Result to Option with .ok() : r/rust - Reddit
I came across this when trying to convert a result into an option. Naturally, I tried .into() assuming that would work (spoiler alert, ......
Read more >How to use Result in Swift
Working with Result First, Result has a get() method that either returns the successful value if it exists, or throws its error otherwise....
Read more >How to use Result correctly? - rust - Stack Overflow
Result is an enum which can be one of two variants: either Ok(. ... Instead what you can do is map the error...
Read more >Recoverable Errors with Result - The Rust Programming ...
When the result is Ok , this code will return the inner file value out of the Ok ... returned by error.kind() is...
Read more >Algebra Calculator - Microsoft Math Solver
In mathematics, a square root of a number x is a number y such that y² = x; in other words, a number...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the speedy fix @chriskrycho! We love to use true-myth 🔮 in our codebase ❤️
Fix released in v5.1.1. Thanks again for the report!