Skip to content

Commit deb4ec3

Browse files
committed
refactoring
1 parent ac5f8e6 commit deb4ec3

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

src/rule/non_empty.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
mod non_empty_iter;
12
mod non_empty_string;
23
mod non_empty_vec;
34

45
use crate::rule::composer::Not;
56
use crate::rule::EmptyRule;
67
use crate::Refined;
78

9+
pub use non_empty_iter::*;
810
pub use non_empty_string::*;
911
pub use non_empty_vec::*;
1012

src/rule/non_empty/non_empty_iter.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use crate::rule::NonEmptyRule;
2+
use crate::Refined;
3+
use std::vec::IntoIter;
4+
5+
pub type NonEmptyIntoIter<T> = Refined<NonEmptyIntoIterRule<T>>;
6+
pub type NonEmptyIntoIterRule<T> = NonEmptyRule<IntoIter<T>>;

src/rule/non_empty/non_empty_vec.rs

+5-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use crate::rule::{EmptyDefinition, NonEmptyRule};
1+
use crate::rule::{EmptyDefinition, NonEmptyIntoIter, NonEmptyRule};
22
use crate::Refined;
3-
use std::iter::Map;
43

4+
use std::iter::Map;
55
use std::ops::Add;
6-
use std::vec::IntoIter;
76

87
impl<I: ExactSizeIterator + EmptyDefinition> Refined<NonEmptyRule<I>> {
98
pub fn map<B, F>(self, f: F) -> Refined<NonEmptyRule<Map<I, F>>>
@@ -21,30 +20,12 @@ impl<I: ExactSizeIterator + EmptyDefinition> Refined<NonEmptyRule<I>> {
2120
where
2221
Self: Sized,
2322
{
24-
let a: B = FromIterator::from_iter(self.into_value());
25-
Refined::new(a).ok().expect("")
23+
Refined::new(FromIterator::from_iter(self.into_value()))
24+
.ok()
25+
.expect("This error is always unreachable")
2626
}
2727
}
2828

29-
pub type NonEmptyIntoIter<T> = Refined<NonEmptyIntoIterRule<T>>;
30-
pub type NonEmptyIntoIterRule<T> = NonEmptyRule<IntoIter<T>>;
31-
32-
pub type NonEmptyMap<I, F> = Refined<NonEmptyMapRule<I, F>>;
33-
pub type NonEmptyMapRule<I, F> = NonEmptyRule<Map<I, F>>;
34-
35-
// impl<T> NonEmptyIntoIter<T> {
36-
// pub fn map<B, F>(self, f: F) -> Refined<NonEmptyRule<Map<IntoIter<T>, F>>>
37-
// where
38-
// Self: Sized,
39-
// F: FnMut(T) -> B,
40-
// {
41-
// let map_into_iter = self.into_value().map(f);
42-
// Refined::new(map_into_iter)
43-
// .ok()
44-
// .expect("This error is always unreachable")
45-
// }
46-
// }
47-
4829
pub type NonEmptyVec<T> = Refined<NonEmptyVecRule<T>>;
4930

5031
impl<T> NonEmptyVec<T>

0 commit comments

Comments
 (0)