Skip to content
Open
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
17 changes: 17 additions & 0 deletions crates/try_v2_derive/tests/test_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ mod bound_ok_type {
FormalError { errno: i32, data: String },
}

impl From<String> for Exit<!> {
fn from(error: String) -> Self {
Self::OtherError(error)
}
}

#[test]
fn short_circuit_1() {
fn fail() -> Exit<()> {
Expand Down Expand Up @@ -77,6 +83,17 @@ mod bound_ok_type {
}
assert_matches!(pass(), Exit::Ok(()))
}

#[test]
fn result_to_exit_via_question_mark() {
fn from_std_result() -> Exit<()> {
let result: Result<(), String> = Err("oops".to_owned());
result?;
Exit::Ok(())
}

assert_matches!(from_std_result(), Exit::OtherError(text) if text == "oops")
}
}

mod multiple_generics {
Expand Down
Loading