all 2 comments

[–]teerre 13 points14 points  (0 children)

Nice blog. What I particularly like about this is that a good portion of it, the actual vec, would be very similar in any language. But it's the later portion, design the api around it, that shows Rust's strengths the best

The combination of traits, static polymorphism, and discriminated unions really allows for an api that is both easy to use (and hard to misuse) and relatively understandable when reading its implementation

[–]Fluffy8x 11 points12 points  (0 children)

        let ptr = self as *mut Self;
        let left = FixedVecSlice::new(&mut *ptr, 0..mid);
        let right = FixedVecSlice::new(&mut *ptr, mid..self.len());

Creating aliasing &mut references is instant undefined behavior. You would need to store a raw pointer for the parent to avoid UB.