rsmorphy 0.4.0

Morphological analyzer / inflection engine for Russian and Ukrainian (soon) languages (WIP)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use container::decode::error::DecodeError;

pub fn follow_str<'s, 'm>(s: &'s str, m: &'m str) -> Result<&'s str, DecodeError> {
    if s.len() < m.len() {
        // FIXME maybe DoesntMatch?
        Err(DecodeError::UnexpectedEnd)?;
    }
    if s.as_bytes()
        .iter()
        .zip(m.as_bytes().iter())
        .all(|(a, b)| a == b)
    {
        Ok(&s[m.len()..])
    } else {
        Err(DecodeError::DoesntMatch)
    }
}