Skip to content

Commit

Permalink
Added comments providing justification for support of calling deref_*…
Browse files Browse the repository at this point in the history
… with wrong variant
  • Loading branch information
Xandkeeper committed May 3, 2018
1 parent c025fde commit e1d5509
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libcore/tests/result.rs
Expand Up @@ -290,7 +290,11 @@ fn test_result_deref() {
let expected_result = Result::Err::<&u32, &[i32]>(&[5, 4, 3, 2, 1][..]);
assert_eq!(ref_err.deref(), expected_result);

// *Odd corner cases (tested for completeness)*
// The following cases test calling deref_* with the wrong variant (i.e.
// `deref_ok()` with a `Result::Err()`, or `deref_err()` with a `Result::Ok()`.
// While unusual, these cases are supported to ensure that an `inner_deref`
// call can still be made even when one of the Result types does not implement
// `Deref` (for example, std::io::Error).

// &Result<T, E: Deref>::Ok(T).deref_err() ->
// Result<&T, &E::Deref::Target>::Ok(&T)
Expand Down

0 comments on commit e1d5509

Please sign in to comment.