def get_matched_rule_ids(matches, query_run):
    """
    Yield the subset of matched rule ids from a `matches` LicenseMatch
    sequence that are within the `query_run` query run.
    """
    qstart = query_run.start
    qend = query_run.end
    for match in matches:
        if qstart <= match.qstart and match.qend <= qend:
            yield match.rule.rid
