PPlamenu
HomeTrendingLive feedsPeopleGroupsRulesStaff
Sign in
PPlamenu
HomeTrendingLive feedsPeopleGroupsRulesStaff
Sign in
plombirka Ⓐ@plombirka@mk.ilyamikcoder.com
⁨14⁩d

is there unwrap_or_err() (or something) in rust that returns an Err() if something goes wrong? or is it stupid and there's no such func/macro?

1000
Open original page
BoostsQuotesFavs
Мя ��@mo@mastodon.ml
⁨14⁩d

Replying to @⁨plombirka@mk.ilyamikcoder.com⁩

@plombirka what return type would such function have...?

1000
Open original page
BoostsQuotesFavs
plombirka Ⓐ@plombirka@mk.ilyamikcoder.com
⁨14⁩d

Replying to @⁨mo@mastodon.ml⁩

@mo@mastodon.ml Option<Ok, Err> or smt?

1000
Open original page
BoostsQuotesFavs
Мя ��@mo@mastodon.ml
⁨14⁩d

Replying to @⁨plombirka@mk.ilyamikcoder.com⁩

@plombirka that's already Result<T, E>, isn't it...?

Or, if your want to drop Ok(T) part, and convert Result<T, E> into Option<E>, there's .err() method

https://doc.rust-lang.org/std/result/enum.Result.html#method.err

(and corresponding .ok() for doing other way)

doc.rust-lang.orgResult in std::result - Rust`Result` is a type that represents either success (`Ok`) or failure (`Err`).
1000
Open original page
BoostsQuotesFavs
plombirka Ⓐ@plombirka@mk.ilyamikcoder.com
⁨14⁩d

Replying to @⁨mo@mastodon.ml⁩

@mo@mastodon.ml yeah, sorry, it meant Result<T, E>. sorry. thx

2000
Open original page
BoostsQuotesFavs
Мя ��@mo@mastodon.ml
⁨14⁩d

Replying to @⁨plombirka@mk.ilyamikcoder.com⁩

@plombirka :neocat_pat_floof:

⁨Aug⁩ ⁨1⁩, ⁨2026⁩, ⁨18:31⁩en
0000
Open original page
BoostsQuotesFavs