Skip to content

Commit d87687b

Browse files
committed
Move custom type test out of unit tests
Also make it conditional on the blanket_impl feature, as UnwrapInfallible is currently effectively sealed without the blanket impl.
1 parent af5de90 commit d87687b

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

src/lib.rs

-23
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,4 @@ mod tests {
9898
let r: Result<bool, !> = Ok(true);
9999
assert!(r.unwrap_infallible());
100100
}
101-
102-
enum MyNeverToken {}
103-
104-
#[cfg(feature = "never_type")]
105-
impl From<MyNeverToken> for ! {
106-
fn from(never: MyNeverToken) -> Self {
107-
match never {}
108-
}
109-
}
110-
111-
#[cfg(not(feature = "blanket_impl"))]
112-
impl<T> UnwrapInfallible for Result<T, MyNeverToken> {
113-
type Ok = T;
114-
fn unwrap_infallible(self) -> T {
115-
self.unwrap_or_else(|never| match never {})
116-
}
117-
}
118-
119-
#[test]
120-
fn with_custom_type() {
121-
let r: Result<bool, MyNeverToken> = Ok(true);
122-
assert!(r.unwrap_infallible());
123-
}
124101
}

tests/blanket_impl.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![cfg(feature = "blanket_impl")]
2+
#![feature(never_type)]
3+
4+
use unwrap_infallible::UnwrapInfallible;
5+
6+
enum MyNeverToken {}
7+
8+
impl From<MyNeverToken> for ! {
9+
fn from(never: MyNeverToken) -> Self {
10+
match never {}
11+
}
12+
}
13+
14+
#[test]
15+
fn with_custom_type() {
16+
let r: Result<bool, MyNeverToken> = Ok(true);
17+
assert!(r.unwrap_infallible());
18+
}

0 commit comments

Comments
 (0)