Flatten a nested if-let
diff --git a/gen/src/alphasort.rs b/gen/src/alphasort.rs
index 7309aa9..18f2896 100644
--- a/gen/src/alphasort.rs
+++ b/gen/src/alphasort.rs
@@ -27,15 +27,12 @@
let mut direct = Vec::new();
let mut nested_namespaces = BTreeMap::new();
for api in &apis {
- if let Some(namespace) = api.namespace() {
- let first_ns_elem = namespace.iter().nth(depth);
- if let Some(first_ns_elem) = first_ns_elem {
- nested_namespaces
- .entry(first_ns_elem)
- .or_insert_with(Vec::new)
- .push(*api);
- continue;
- }
+ if let Some(first_ns_elem) = api.namespace().and_then(|ns| ns.iter().nth(depth)) {
+ nested_namespaces
+ .entry(first_ns_elem)
+ .or_insert_with(Vec::new)
+ .push(*api);
+ continue;
}
direct.push(*api);
}