---
title: "Rust programming language: use cases and examples"
description: "See where the Rust programming language fits (systems, Wasm, games, networking) with short examples of variables, control flow, and structs."
canonical_url: https://www.oguzhan.co/rust-programming-language-use-cases-examples/
author: "Oğuzhan Koçaklı"
author_url: https://www.oguzhan.co/about/
date_published: 2023-03-20T13:30:00+00:00
date_modified: 2026-09-14T05:50:46+00:00
language: en
translations:
  tr: https://www.oguzhan.co/tr/rust-programlama-dilinin-kullanim-alanlari-ve-ornekler/
---

# Rust programming language: use cases and examples

Rust, originally from Mozilla, is a modern language built around performance, memory safety, and concurrency. It targets low-level systems work and stands out with ownership rules that catch data races early. Here is where it shows up, plus a few small examples.

## Where Rust is a good fit

- **Systems programming:** OS pieces, embedded work, and drivers benefit from speed without the usual memory foot-guns.
- **WebAssembly:** Rust compiles cleanly to Wasm for fast, safer browser-side code.
- **Games:** Useful when you need performance and safer memory behavior in engine or tooling code.
- **Networking:** Strong for services that must stay fast and careful under load.
- **Parallel and concurrent work:** The type system and ownership model help structure concurrent programs.

## Rust examples

Below are tiny samples of everyday Rust.

**a. Hello world**

```
fn main() {
    println!("Hello, world!");
}
```

**b. Variables and constants**

```
fn main() {
    let x = 10; // immutable
    let mut y = 20; // mutable
    const Z: i32 = 30;

    y = 25;
    println!("x: {}, y: {}, Z: {}", x, y, Z);
}
```

**c. Control flow**

```
fn main() {
    let x = 5;

    if x > 10 {
        println!("x is greater than 10.");
    } else {
        println!("x is less than or equal to 10.");
    }

    for i in 1..6 {
        println!("i: {}", i);
    }

    let mut counter = 1;
    while counter <= 5 {
        println!("counter: {}", counter);
        counter += 1;
    }

    let number = 3;
    match number {
        1 => println!("One"),
        2 => println!("Two"),
        3 => println!("Three"),
        _ => println!("Other"),
    }
}
```

**d. Functions**

```
fn main() {
    let x = 5;
    let y = 10;
    let result = add(x, y);
    println!("Sum: {}", result);
}

fn add(a: i32, b: i32) -> i32 {
    a + b
}
```

**e. Structs and enums**

```
struct Point {
    x: f64,
    y: f64,
}

enum Direction {
    Up,
    Down,
    Left,
    Right,
}

fn main() {
    let p = Point { x: 3.0, y: 4.0 };
    println!("Point: ({}, {})", p.x, p.y);

    let direction = Direction::Up;
    match direction {
        Direction::Up => println!("Up"),
        Direction::Down => println!("Down"),
        Direction::Left => println!("Left"),
        Direction::Right => println!("Right"),
    }
}
```

## Wrap-up

Rust rewards teams that care about performance and safety at the same time. Learn the ownership model, work through small examples, and it becomes a sharp tool for systems, Wasm, games, networking, and concurrent services.
