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?
Replying to @plombirka@mk.ilyamikcoder.com
@plombirka what return type would such function have...?
@mo@mastodon.ml Option<Ok, Err> or smt?
Replying to @plombirka@mk.ilyamikcoder.com
@mo@mastodon.ml энивей, есть ли что-то вроде unwrap_or(Err()), чтоб можно было вызвать в функции которая вернула бы Result<T,E> в случае, если unwrap не сможет unwrap'нуть, чтоб можно было вне этой функции через match фсё обработать без паники?
@plombirka можешь вообще показать поболбше контекста? Как ты хочешь перекинуть данные между функциями..?
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)
@mo@mastodon.ml yeah, sorry, it meant Result<T, E>. sorry. thx
Replying to @plombirka@mk.ilyamikcoder.com
@plombirka аэээ... есть оператор `?`, который либо даст тебе Ok() либо сделает `return Err()` из функции
https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#the--operator-shortcut
