Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add update to Rust post #171

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions en/_posts/2025-02-03-rust-first-impressions-error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ of these methods are basically an `if` statement that does different things in
the case that an error is encountered. This heavily favors the style in Rust of
chaining logic together and using closures which can easily get unwieldy.

> **Update:** The Rust `Result` type is not actaully implemented as tuple but
> an
> [`enum`](https://github.com/rust-lang/rust/blob/affdb59607566c1615c829eea9e7b27a093994ec/library/core/src/result.rs#L528n).
> This means that it cannot return both a return value and error at the same
> time like a tuple would. It also stores it in slightly less memory since the
> `enum` just needs to store the `enum` variant and value.

```rust
// Why this?
if result.is_err_and(|x| x.kind() == ErrorKind::NotFound) { /* … */ }
Expand Down
Loading