Rust solution
rust\nimpl Solution {\n    pub fn find_closest_elements(arr: Vec<i32>, k: i32, x: i32) -> Vec<i32> {\n        let k = k as usize;\n        let mut l = 0;\n     
```rust\nimpl Solution {\n    pub fn find_closest_elements(arr: Vec<i32>, k: i32, x: i32) -> Vec<i32> {\n        let k = k as usize;\n        let mut l = 0;\n        let mut r = arr.len() - k;\n        while l < r {\n            let mid = l + (r - l) / 2;\n            if x - arr[mid] > arr[mid + k] - x {\n                l = mid + 1;\n            } else {\n                r = mid;\n            }\n        }\n        arr[l..(l + k)].into()\n    }\n}\n```\n
['Rust']