1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use futures::{future, StreamExt};
use super::Work;
use crate::result::Result;
impl<'a> Work<'a> {
pub fn include(self, re: impl Into<String>) -> Result<Work<'a>> {
let re = regex::Regex::new(&re.into())?;
self.add_work(move |elements| {
elements
.filter(move |element| {
future::ready(
re.is_match(element.get_file().path().as_path().to_str().unwrap()),
)
})
.boxed()
})
}
pub fn exclude(self, re: impl Into<String>) -> Result<Work<'a>> {
let re = regex::Regex::new(&re.into())?;
self.add_work(move |elements| {
elements
.filter(move |element| {
future::ready(
!re.is_match(element.get_file().path().as_path().to_str().unwrap()),
)
})
.boxed()
})
}
}