aboutsummaryrefslogtreecommitdiff
path: root/src/filter/string.rs
blob: ea476e42f934fd80d1314f73737e320994281072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::fmt;

#[derive(Debug)]
pub struct Filter {
    inner: String,
}

impl Filter {
    pub fn new(spec: &str) -> Result<Filter, String> {
        Ok(Filter {
            inner: spec.to_string(),
        })
    }

    pub fn is_match(&self, s: &str) -> bool {
        s.contains(&self.inner)
    }
}

impl fmt::Display for Filter {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        self.inner.fmt(f)
    }
}