[Rust] solution
```\nuse std::cmp::max;\nimpl Solution {\n    pub fn largest_component_size(nums: Vec) -> i32 {\n        let mut par: Vec = vec![0; 100001];\n        let mut ra
```\nuse std::cmp::max;\nimpl Solution {\n    pub fn largest_component_size(nums: Vec<i32>) -> i32 {\n        let mut par: Vec<i32> = vec![0; 100001];\n        let mut rank: Vec<i32> = vec![0; 100001];\n        let mut ans: i32 = 1;\n        \n        for i in 1..=100000{\n            par[i] = i as i32;\n        }\n        \n        for i in 0..nums.len() {\n            rank[nums[i] as usize] = 1;\n        }\n        \n        for i in 0..nums.len() {\n            let mut j: usize = 2;\n            while j*j <= nums[i] as usize  {\n                if(nums[i] as usize % j == 0)\n                {\n                    Solution::union(j, nums[i] as usize, &mut par, &mut rank, &mut ans);\n                    Solution::union(j, (nums[i] as usize/j), &mut par, &mut rank, &mut ans);\n                }\n                j+=1;\n            }\n        }\n        return ans;\n    }\n    \n    fn find(x: usize, par: &mut Vec<i32>) -> usize {\n        return if par[x] == x as i32 {x} else {par[x] = Solution::find(par[x] as usize, par) as i32; return par[x] as usize};\n    }\n    \n    fn union(a: usize, b: usize, par: &mut Vec<i32>, rank: &mut Vec<i32>, ans: &mut i32) {\n        \n        let a = Solution::find(a, par); \n        let b = Solution::find(b, par);\n        \n        if(a==b) {return;}\n        \n        if(rank[a]>=rank[b]){\n            par[b]=a as i32; rank[a] += rank[b];\n        }\n        \n        else {\n            rank[b] += rank[a]; par[a]=b as i32;\n        }\n        *ans = max(*ans, max(rank[a],rank[b]));\n    }\n}
['Rust']