this post was submitted on 23 Jan 2024
362 points (96.6% liked)
Fediverse
28490 readers
341 users here now
A community to talk about the Fediverse and all it's related services using ActivityPub (Mastodon, Lemmy, KBin, etc).
If you wanted to get help with moderating your own community then head over to !moderators@lemmy.world!
Rules
- Posts must be on topic.
- Be respectful of others.
- Cite the sources used for graphs and other statistics.
- Follow the general Lemmy.world rules.
Learn more at these websites: Join The Fediverse Wiki, Fediverse.info, Wikipedia Page, The Federation Info (Stats), FediDB (Stats), Sub Rehab (Reddit Migration), Search Lemmy
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If I except a boolean, there is an error and get a Result, is Result an object? How do I know if I get a bool or error?
Here's some examples written on my phone:
And there's many other awesome ways to use a Result including turning it into an Option or unwrapping it unsafely. I recommend you just search "Rust book" on your search engine and browse it. Here's the docs to the Result enum.
Ah, so it is like a wrapper enum,
ok
contains the data type you want anderr
the error object?Exactly! The other wrapper enum I named (Option) is the same kind of concept but with
Some(value)
andNone
.