Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Rust's Result(T) in Go with Go Generics (github.com)
1 point by reconquestio 15 days ago | hide | past | favorite | 2 comments



I'm not entirely familiar with the Rust type or the latest Go proposal but is there a way to do this without possibility of cleanly compiled source panicking at run time?

Something like if Result didn't include those possibly panicking functions and wider types ResultOk and ResultErr had the corresponding functions guaranteed not to panic. These types would only be accessible from Result upon checking.


No, it isn’t possible. FTA:

“Unfortunately, it can't be ported completely due to lack of pattern matching in Go.

The only possible way was to use channels and select {}, but it would be too complicated and it would be just an imitation.”

I don’t understand how the solution using channels would work.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: