pub fn longest_common_prefix<'a, I, S>(iter: I) -> Option<&'a str> where
        I: IntoIterator<Item=&'a S>,
        S: 'a + ?Sized + AsRef<str>,
        {
    let mut iter = iter.into_iter();

    let mut pfx = iter.next()?.as_ref();

    for s in iter {
        let s = s.as_ref();

        let n = pfx.chars().zip(s.chars())
            .take_while(|&(a, b)| a == b)
            .map(|(ch, _)| ch.len_utf8()).sum();

        if n == 0 {
            return None;
        } else {
            pfx = &pfx[..n];
        }
    }

    Some(pfx)
}
/// Returns the longest common prefix of a set of strings.
///
/// If no common prefix exists, `None` is returned.
Returns the longest common prefix of a set of strings.
If no common prefix exists, `None` is returned.
Returns the longest common prefix of a set of strings . If no common prefix exists ` None ` is returned .
pub fn longest_common_prefix<'a, I, S>(iter: I) -> Option<&'a str> where
        I: IntoIterator<Item=&'a S>,
        S: 'a + ?Sized + AsRef<str>,
        {
    let mut iter = iter.into_iter();
    let mut pfx = iter.next()?.as_ref();
    for s in iter {
        let s = s.as_ref();
        let n = pfx.chars().zip(s.chars())
            .take_while(|&(a, b)| a == b)
            .map(|(ch, _)| ch.len_utf8()).sum();
        if n == 0 {
            return None;
        } else {
            pfx = &pfx[..n];
        }
    }
    Some(pfx)
}
pub fn longest_common_prefix < ' a , I , S > ( iter : I ) -> Option < & ' a str > where I : IntoIterator < Item = & ' a S > , S : ' a + ? Sized + AsRef < str > , { let mut iter = iter . into_iter ( ) ; let mut pfx = iter . next ( ) ? . as_ref ( ) ; for s in iter { let s = s . as_ref ( ) ; let n = pfx . chars ( ) . zip ( s . chars ( ) ) . take_while ( | & ( a , b ) | a == b ) . map ( | ( ch , _ ) | ch . len_utf8 ( ) ) . sum ( ) ; if n == 0 { return None ; } else { pfx = & pfx [ .. n ] ; } } Some ( pfx ) }
Returns the longest common prefix of a set of strings.
Returns the longest common prefix of a set of strings .
iter
I
iter
I