diff options
author | Kornel <kornel@geekhood.net> | 2019-08-03 19:39:11 +0100 |
---|---|---|
committer | Kornel <kornel@geekhood.net> | 2019-08-03 20:01:44 +0100 |
commit | 4fed0b350b781863e0e0e7c4bee7e407d2c1e12e (patch) | |
tree | 3cfccf0745d2f3d45a2ec75914d1195e43e02086 /categories/src | |
parent | 42a5a9051c81527441b2c7b6077a19a6b64d7916 (diff) |
Move category fudge to reading stage
Diffstat (limited to 'categories/src')
-rw-r--r-- | categories/src/categories.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/categories/src/categories.rs b/categories/src/categories.rs index ebb3c2c..7840457 100644 --- a/categories/src/categories.rs +++ b/categories/src/categories.rs @@ -110,8 +110,8 @@ impl Categories { }).collect() } - pub fn fixed_category_slugs(cats: &[String]) -> Vec<Cow<'_, str>> { - let mut cats = cats.iter().enumerate().filter_map(|(idx, s)| { + pub fn filtered_category_slugs(cats: &[String]) -> impl Iterator<Item=&str> { + cats.iter().filter_map(|s| { if s.len() < 2 { return None; } @@ -121,6 +121,12 @@ impl Categories { if s == "api-bindings" { // We pretend it doesn't exist return None; } + Some(s.as_str()) + }) + } + + pub fn fixed_category_slugs(cats: &[String]) -> Vec<Cow<'_, str>> { + let mut cats = Self::filtered_category_slugs(cats).enumerate().filter_map(|(idx, s)| { let mut chars = s.chars().peekable(); while let Some(cur) = chars.next() { // look for a:b instead of a::b |