You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: _373_find_k_pairs_with_smallest_sums.rs
    path of file: ./repos/rustgym/leetcode/src/d3
    
    the code of the file until where you have to start completion: struct Solution;
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::collections::HashSet;

impl Solution {
    fn k_smallest_pairs(nums1: Vec<i32>, nums2: Vec<i32>, mut k: i32) -> Vec<Vec<i32>> {
        let n1 = nums1.len();
        let n2 = nums2.len();
        let mut visited: HashSet<(usize, usize)> = HashSet::new();
        let mut queue: BinaryHeap<(Reverse<i32>, usize, usize)> = BinaryHeap::new();
        if 0 < n1 && 0 < n2 && visited.i
    
    fn k_smallest_pairs(nums1: Vec<i32>, nums2: Vec<i32>, mut k: i32) -> Vec<Vec<i32>> {
        let n1 = nums1.len();
        let n2 = nums2.len();
        let mut visited: HashSet<(usize, usize)> = HashSet::new();
        let mut queue: BinaryHeap<(Reverse<i32>, usize, usize)> = BinaryHeap::new();
        if 0 < n1 && 0 < n2 && visited.insert((0, 0)) {
            queue.push((Reverse(nums1[0] + nums2[0]), 0, 0));
        } else {
            return vec![];
        }
        let mut res = vec![];
        while k > 0 {
            if let Some((_, i, j)) = queue.pop() {
                res.push(vec![nums1[i], nums2[j]]);
                if i + 1 < n1 && visited.insert((i + 1, j)) {
                    queue.push((Reverse(nums1[i + 1] + nums2[j]), i + 1, j));
                }
                if j + 1 < n2 && visited.insert((i, j + 1)) {
                    queue.push((Reverse(nums1[i] + nums2[j + 1]), i, j + 1));
                }
                k -= 1;
            } else {
                break;
            }
        }
        res
    }