Skip to content

Commit 4850993

Browse files
committed
Move test to right spot, and fix conditional compilation
1 parent 252969f commit 4850993

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/exactly_one_err.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#[cfg(feature = "use_std")]
22
use std::error::Error;
3-
#[cfg(feature = "use_std")]
43
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
54

65
use std::iter::ExactSizeIterator;
@@ -73,7 +72,6 @@ where
7372

7473
impl<I> ExactSizeIterator for ExactlyOneError<I> where I: ExactSizeIterator {}
7574

76-
#[cfg(feature = "use_std")]
7775
impl<I> Display for ExactlyOneError<I>
7876
where I: Iterator
7977
{
@@ -87,7 +85,6 @@ impl<I> Display for ExactlyOneError<I>
8785
}
8886
}
8987

90-
#[cfg(feature = "use_std")]
9188
impl<I> Debug for ExactlyOneError<I>
9289
where I: Iterator,
9390
I::Item: Debug,
@@ -110,17 +107,4 @@ impl<I> Debug for ExactlyOneError<I>
110107
#[cfg(feature = "use_std")]
111108
impl<I> Error for ExactlyOneError<I> where I: Iterator, I::Item: Debug, {}
112109

113-
#[cfg(all(test, feature = "use_std"))]
114-
mod tests {
115-
use super::*;
116110

117-
#[test]
118-
fn question_mark_syntax_works() {
119-
question_mark_return().unwrap_err()
120-
}
121-
122-
fn question_mark_return() -> Result<(), impl Error> {
123-
let x = Err(ExactlyOneError::new(None, []))?;
124-
Ok(())
125-
}
126-
}

tests/test_std.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use permutohedron;
22
use itertools as it;
33
use crate::it::Itertools;
4+
use crate::it::ExactlyOneError;
45
use crate::it::multizip;
56
use crate::it::multipeek;
67
use crate::it::peek_nth;
@@ -913,3 +914,13 @@ fn tree_fold1() {
913914
assert_eq!(actual, expected);
914915
}
915916
}
917+
918+
#[test]
919+
fn exactly_one_question_mark_syntax_works() {
920+
exactly_one_question_mark_return().unwrap_err();
921+
}
922+
923+
fn exactly_one_question_mark_return() -> Result<(), ExactlyOneError<std::slice::Iter<'static, ()>>> {
924+
[].iter().exactly_one()?;
925+
Ok(())
926+
}

0 commit comments

Comments
 (0)