expression

Calculate the length of a 2D vector

Vector length measures magnitude rather than direction. The Euclidean length is the square root of the sum of squared coordinates. For floating-point inputs, hypot avoids unnecessary intermediate overflow or underflow compared with directly squaring components. The tiny fixed example gives a 3-4-5 triangle. Expected result (NOT RUN): length: 5.0 Common mistake: Adding coordinates instead of measuring Euclidean length. Static Rust example; not a verified ByteMind executable assessment.

Formal Syntax & Structure

rust syntaxrust
x.hypot(y)

Working Example

Example Snippetrust
fn main() {    let (x, y) = (3.0_f64, 4.0_f64);    println!("length: {:.1}", x.hypot(y));}
Rust Reference