← All Exercises

Rust Unsafe and FFI

advancedrust~35min

Background

Unsafe Rust bypasses safety guarantees for low-level operations, FFI, and performance-critical code.

Problem

Write a Rust function that uses unsafe to split a vector into two parts at a given index using raw pointers.

Input

A mutable vector and a split index.

Output

Two vectors split at the given index.

Sample tests

Sample 1

Input: [1,2,3,4,5], split at 3
Expected: [1,2,3], [4,5]

Your solution

Learning objective

Understand unsafe Rust, raw pointer operations, FFI basics, and safety boundaries.