changing values in a vector I am looking to have a code review on this tiny repository.

The code seems to work, but I am not sure if I have written it in idiomatic Rust.

#[derive(Debug)]
pub struct QuickFind {
    items: Vec&lt;u64&gt;,
}

impl QuickFind {
    pub fn new(length: u64) -&gt; QuickFind {
        let mut result: QuickFind = QuickFind { items: Vec::new() };

        for i in 0..length {
            result.items.push(i);
        }

        result
    }

    pub fn union(&amp;mut self, left_index: u64, right_index: u64) {
        let left_group_id = self.items[left_index as usize];

        self.items[right_index as usize] = left_group_id;
    }

    pub fn get_items(&amp;self) -&gt; &amp;[u64] {
        &amp;self.items
    }

    pub fn is_connected(&amp;self, left_index: u64, right_index: u64) -&gt; bool {
        self.items[left_index as usize] == self.items[right_index as usize]
    }
}
Collect the iterator into the new vector

You don't need to loop over a range to populate a vector with elements. The collect method has enough information to construct a Vec&lt;u64&gt; on the spot. This also makes the result variable unnecessary.

    pub fn new(length: u64) -&gt; QuickFind {
        QuickFind {
            items: (0..length).collect(),
        }
    }


C-GETTER

The convention for getter names is without the prefix get_, unless get makes up the entire method name. get_items(&amp;self) becomes items(&amp;self).

Reconsider usize as the index type.

There appear to be multiple conversions from u64 to usize in the code. Indeed, usize is the common integral type for referring to a relative (non-negative) position of a value in memory. With that done, the only integer cast is in new, so as to turn the range (0..length) into a range of values rather than a range of indices.

The final code:

Playground

#[derive(Debug)]
pub struct QuickFind {
    items: Vec&lt;u64&gt;,
}

impl QuickFind {
    pub fn new(length: usize) -&gt; QuickFind {
        QuickFind {
            items: (0..length as u64).collect(),
        }
    }

    pub fn union(&amp;mut self, left_index: usize, right_index: usize) {
        let left_group_id = self.items[left_index];

        self.items[right_index] = left_group_id;
    }

    pub fn items(&amp;self) -&gt; &amp;[u64] {
        &amp;self.items
    }

    pub fn is_connected(&amp;self, left_index: usize, right_index: usize) -&gt; bool {
        self.items[left_index] == self.items[right_index]
    }
}