about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrad Gibson <b2b@humanenginuity.com>2018-05-02 19:16:29 -0700
committerBrad Gibson <b2b@humanenginuity.com>2018-05-02 19:16:29 -0700
commite1d5509bf381d978a1894b6ba869c3b56dd3eeca (patch)
tree5a1007678dfe1b717554121fb8b71e80e1f9e60c
parentc025fdebbada2757deccdd97219ff0313631f2ed (diff)
downloadrust-e1d5509bf381d978a1894b6ba869c3b56dd3eeca.tar.gz
rust-e1d5509bf381d978a1894b6ba869c3b56dd3eeca.zip
Added comments providing justification for support of calling deref_* with wrong variant
-rw-r--r--src/libcore/tests/result.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcore/tests/result.rs b/src/libcore/tests/result.rs
index fd0dd21401b..f8b5ea5e16e 100644
--- a/src/libcore/tests/result.rs
+++ b/src/libcore/tests/result.rs
@@ -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)