Translating TypeScript to Rust #3

Translating TypeScript to Rust #3

Remember that every translation is subject to inaccuracies in some cases. Feel free to correct or suggest better translations in the comments.

3.1 - Tuples

TypeScript

const position: [number, number] = [23.45348, 24.92868];

Rust

let position: (f32, f32) = (23.45348, 24.92868);

3.2 - Arrays

TypeScript

const array = [1, 2, 3, 4];

Rust

let array = [1, 2, 3, 4];

3.3 - Building (Transpiling & Compiling)

TypeScript

$ npx tsc

Rust

$ cargo build

3.4 - Ternary operator

TypeScript

const condition: boolean = true;
const result: number = condition ? 1 : 2;

Rust

let condition: bool = true;
let result: i32 = if condition { 1 } else { 2 };