Oh! Idea (assuming that interpretation is correct): sort the list of directives from longest to shortest on initialisation, then this function can be simplified to

```rust
let requested_level = DEFAULT_LOG_LEVEL;
// run through the directives from longest to shortest
for directive in iter {
    if module.starts_with(directive.name) {
        // a match! the ordering means that this is automatically the longest 
        // match, so we accept it
        requested_lvl = directive.level;
        break;
    }
}
// if no match is found then we haven't modified `requested_lvl` i.e. use the default

level <= requested_lvl
```

(I guess this doesn't work if we get glob/regex matching with `RUST_LOG`, although we'd need a better defined concept of specificity there anyway.)