Skip to content

Commit

Permalink
Move test to right spot, and fix conditional compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaeroxe committed Sep 29, 2020
1 parent 252969f commit 4850993
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/exactly_one_err.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#[cfg(feature = "use_std")]
use std::error::Error;
#[cfg(feature = "use_std")]
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};

use std::iter::ExactSizeIterator;
Expand Down Expand Up @@ -73,7 +72,6 @@ where

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

#[cfg(feature = "use_std")]
impl<I> Display for ExactlyOneError<I>
where I: Iterator
{
Expand All @@ -87,7 +85,6 @@ impl<I> Display for ExactlyOneError<I>
}
}

#[cfg(feature = "use_std")]
impl<I> Debug for ExactlyOneError<I>
where I: Iterator,
I::Item: Debug,
Expand All @@ -110,17 +107,4 @@ impl<I> Debug for ExactlyOneError<I>
#[cfg(feature = "use_std")]
impl<I> Error for ExactlyOneError<I> where I: Iterator, I::Item: Debug, {}

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

#[test]
fn question_mark_syntax_works() {
question_mark_return().unwrap_err()
}

fn question_mark_return() -> Result<(), impl Error> {
let x = Err(ExactlyOneError::new(None, []))?;
Ok(())
}
}
11 changes: 11 additions & 0 deletions tests/test_std.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use permutohedron;
use itertools as it;
use crate::it::Itertools;
use crate::it::ExactlyOneError;
use crate::it::multizip;
use crate::it::multipeek;
use crate::it::peek_nth;
Expand Down Expand Up @@ -913,3 +914,13 @@ fn tree_fold1() {
assert_eq!(actual, expected);
}
}

#[test]
fn exactly_one_question_mark_syntax_works() {
exactly_one_question_mark_return().unwrap_err();
}

fn exactly_one_question_mark_return() -> Result<(), ExactlyOneError<std::slice::Iter<'static, ()>>> {
[].iter().exactly_one()?;
Ok(())
}

0 comments on commit 4850993

Please sign in to comment.