pub fn lookup<'a>(&'a self, query: &str) -> Vec<&'a FeatureData> {
        let mut feats = vec![];

        // TODO: totally no logic to any of this

        for feature in self.features.values() {
            if feature.slug.to_lowercase().contains(query) {
                feats.push(feature);
                continue;
            }

            if feature
                .flag
                .as_deref()
                .map(|flag| flag.to_lowercase().contains(query))
                .unwrap_or(false)
            {
                feats.push(feature);
                continue;
            }

            if feature.title.to_lowercase().contains(query) {
                feats.push(feature);
                continue;
            }

            for item in &feature.items {
                if item.to_lowercase().contains(query) {
                    feats.push(feature);
                    continue;
                }
            }

            for item in &feature.aliases {
                if item.to_lowercase().contains(query) {
                    feats.push(feature);
                    continue;
                }
            }

            if strsim::sorensen_dice(query, &feature.slug.to_lowercase()) > 0.65 {
                feats.push(feature);
                continue;
            }

            if let Some(flag) = feature.flag.as_deref() {
                if strsim::sorensen_dice(query, &flag.to_lowercase()) > 0.65 {
                    feats.push(feature);
                    continue;
                }
            }

            if strsim::sorensen_dice(query, &feature.title.to_lowercase()) > 0.4 {
                feats.push(feature);
                continue;
            }
        }

        feats
    }
/// Fuzzy finds ~up to 20~ of the most relevant features in the database.
Fuzzy finds ~up to 20~ of the most relevant features in the database.
Fuzzy finds ~up to 20~ of the most relevant features in the database .
pub fn lookup<'a>(&'a self, query: &str) -> Vec<&'a FeatureData> {
        let mut feats = vec![];
        // TODO: totally no logic to any of this
        for feature in self.features.values() {
            if feature.slug.to_lowercase().contains(query) {
                feats.push(feature);
                continue;
            }
            if feature
                .flag
                .as_deref()
                .map(|flag| flag.to_lowercase().contains(query))
                .unwrap_or(false)
            {
                feats.push(feature);
                continue;
            }
            if feature.title.to_lowercase().contains(query) {
                feats.push(feature);
                continue;
            }
            for item in &feature.items {
                if item.to_lowercase().contains(query) {
                    feats.push(feature);
                    continue;
                }
            }
            for item in &feature.aliases {
                if item.to_lowercase().contains(query) {
                    feats.push(feature);
                    continue;
                }
            }
            if strsim::sorensen_dice(query, &feature.slug.to_lowercase()) > 0.65 {
                feats.push(feature);
                continue;
            }
            if let Some(flag) = feature.flag.as_deref() {
                if strsim::sorensen_dice(query, &flag.to_lowercase()) > 0.65 {
                    feats.push(feature);
                    continue;
                }
            }
            if strsim::sorensen_dice(query, &feature.title.to_lowercase()) > 0.4 {
                feats.push(feature);
                continue;
            }
        }
        feats
    }
pub fn lookup < ' a > ( & ' a self , query : & str ) -> Vec < & ' a FeatureData > { let mut feats = vec ! [ ] ; // TODO: totally no logic to any of this for feature in self . features . values ( ) { if feature . slug . to_lowercase ( ) . contains ( query ) { feats . push ( feature ) ; continue ; } if feature . flag . as_deref ( ) . map ( | flag | flag . to_lowercase ( ) . contains ( query ) ) . unwrap_or ( false ) { feats . push ( feature ) ; continue ; } if feature . title . to_lowercase ( ) . contains ( query ) { feats . push ( feature ) ; continue ; } for item in & feature . items { if item . to_lowercase ( ) . contains ( query ) { feats . push ( feature ) ; continue ; } } for item in & feature . aliases { if item . to_lowercase ( ) . contains ( query ) { feats . push ( feature ) ; continue ; } } if strsim :: sorensen_dice ( query , & feature . slug . to_lowercase ( ) ) > 0.65 { feats . push ( feature ) ; continue ; } if let Some ( flag ) = feature . flag . as_deref ( ) { if strsim :: sorensen_dice ( query , & flag . to_lowercase ( ) ) > 0.65 { feats . push ( feature ) ; continue ; } } if strsim :: sorensen_dice ( query , & feature . title . to_lowercase ( ) ) > 0.4 { feats . push ( feature ) ; continue ; } } feats }
Fuzzy finds ~up to 20~ of the most relevant features in the database.
Fuzzy finds ~up to 20~ of the most relevant features in the database .
&'a self
query
&str
&'a self
query
&str