Can you show me an example of rewriting some hairy C++ code to Rust?
I'd be happy to help. Please provide the hairy C++ code you'd like to see rewritten in Rust, and I'll do my best to create a more idiomatic and safe Rust equivalent.

If you don't have a specific example, I can provide a generic one. Here's a simple example of rewriting a C++ code that uses raw pointers and manual memory management to a Rust version that uses smart pointers and ownership:

**C++ Code:**
```cpp
#include <iostream>

class Person {
public:
    Person(const char* name, int age) : name_(new char[strlen(name) + 1]) {
        strcpy(name_, name);
        age_ = age;
    }

    ~Person() {
        delete[] name_;
    }

    void print() {
        std::cout << "Name: " << name_ << ", Age: " << age_ << std::endl;
    }

private:
    char* name_;
    int age_;
};

int main() {
    Person* person = new Person("John Doe", 30);
    person->print();
    delete person;
    return 0;
}
```
**Rust Code:**
```rust
struct Person {
    name: String,
    age: i32,
}

impl Person {
    fn new(name: &str, age: i32) -> Self {
        Person {
            name: name.to_string(),
            age,
        }
    }

    fn print(&self) {
       
Certainly! Let's take a simple example of a C++ class that manages a list of integers. We'll rewrite it in Rust, focusing on key differences in syntax, memory management, and safety features.

### C++ Code Example

Here’s a simple C++ class that manages a dynamic array of integers:

```cpp
#include <iostream>

class IntList {
private:
    int* data;
    size_t size;
    size_t capacity;

public:
    IntList() : size(0), capacity(10) {
        data = new int[capacity];
    }

    ~IntList() {
        delete[] data;
    }

    void add(int value) {
        if (size >= capacity) {
            capacity *= 2;
            int* newData = new int[capacity];
            for (size_t i = 0; i < size; ++i) {
                newData[i] = data[i];
            }
            delete[] data;
            data = newData;
        }
        data[size++] = value;
    }

    void print() const {
        for (size_t i = 0; i < size; ++i) {
            std::cout << data[i] << " ";
        }
        std::cout << std::endl;
    }
};

int main() {
    IntList list;
    list.add(1);
    list.add(2);
    list.add(3);
    list.print();
    return 0;
}
```

### Rust