# Common Data Structures

{% embed url="<https://openguild-labs.github.io/open-rust/syllabus/module/1.4-slides.html>" %}

## Enumeration

{% embed url="<https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html>" %}
Learn about Enum in the Rust programming language book
{% endembed %}

<figure><img src="/files/2LnwBIRDAE3N02YL3ICU" alt=""><figcaption><p>Bullet points of the enumeration</p></figcaption></figure>

An enumeration, or enum, is a data type that allows a variable to take on one of several possible values (or states). Each of these possibilities is called a "variant." For example, in Rust, an enum can represent different states of a traffic light with variants such as `Red`, `Yellow`, and `Green`.

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

fn which_way(go: Direction) -> &'static str {
    match go {
        Direction::Up => "up",
        Direction::Down => "down",
        Direction::Left => "left",
        Direction::Right => "right",
    }
}
```

## Structure

<figure><img src="/files/KO85L8QjnOnWbnQzsMDa" alt=""><figcaption></figcaption></figure>

```rust
struct ShippingBox {
    depth: i32,
    width: i32,
    height: i32,
}

fn main() {
    let my_box = ShippingBox {
        depth: 3,
        width: 2,
        height: 5,
    };

    let tall = my_box.height;
    println!("the box is {:?} units tall", tall);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bootcamp.openguild.wtf/rust-programming-language/basic-rust/common-data-structures.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
