Rust solution with HashMap
Since there is only one rust-tagged solution for this problem, I will post another one which is \ntaken from here https://rustgym.com/leetcode/1656\n\nrust\nuse
Since there is only one rust-tagged solution for this problem, I will post another one which is \ntaken from here https://rustgym.com/leetcode/1656\n\n```rust\nuse std::collections::HashMap;\n\nstruct OrderedStream {\n    kv: HashMap<i32, String>,\n    n: i32, \n    i: i32,\n}\n\n/** \n * `&self` means the method takes an immutable reference.\n * If you need a mutable reference, change it to `&mut self` instead.\n */\nimpl OrderedStream {\n\n    fn new(n: i32) -> Self {\n        OrderedStream {\n            kv: HashMap::new(),\n            n: n,\n            i: 1\n        }\n    }\n    \n    fn insert(&mut self, id_key: i32, value: String) -> Vec<String> {\n        self.kv.insert(id_key, value);\n        let mut res: Vec<String> = Vec::new();\n        if self.i == id_key {\n            for j in id_key..=self.n {\n                if let Some(v) = self.kv.get(&j) {\n                    res.push(v.to_string());\n                    self.i += 1;\n                } else {\n                    break;\n                }\n            }\n        }\n        return res;\n    }\n}\n```
['Rust']