Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.

use anyhow::Result;

fn main() -> Result<()> {
    let a = std::fs::File::open("nonexistant")?;
    let _ = a;
    Ok(())
}


Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.

use anyhow::Result;

fn main() -> Result<()> {
    let num = 1 / 0;
    let _ = num;
    Ok(())
}


Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.

use anyhow::{Context, Result};
use std::fs;

fn main() -> anyhow::Result<()> {
    let contents = fs::read_to_string("example.txt")?;
    let len = contents.len();

    println!("file size: {}", len);

    Ok(())
}


Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.


Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.

use anyhow::Result;
use std::fs;

fn main() -> Result<()> {
    let file = fs::File::open("non_existent_file.txt")?;
    Ok(())
}


Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.

use anyhow::Result;
use anyhow::bail;
use anyhow::Context;

fn main() -> Result<()> {
    let a = String::from("hello");
    let b = a.clone();

    let c = a + b;
    let d = a + &b;

    let e = b + a;
    let f = &b + a;

    let g = &a + b;
    let h = &a + &b;

    let i = a + &b;
    let j = &a + &b;

    let k = b + &a;
    let l = &b + &a;

    let m = &b + a;
    let n = &b + &a;

    let o = &a + b;
    let p = &a + &b;

    let q = &a + &b;
    let r = &a + &b;

    let s = b + &a;
    let t = &b + &a;

    let u = &b + a;
    let v = &b + &a;

    let w = &a + b;
    let x = &a + &b;

    let y = &a + &b;
    let z = &a + &b;

    Ok(())
}


Prompt: Write only a single Rust source file (main.rs) with a `fn main() -> anyhow::Result<()>` that demonstrates basic anyhow error handling. Do not explain; output only Rust code wrapped in ```rust code blocks.

use anyhow::{anyhow, Context, Result};
use std::env;
use std::fs;
use std::process;

fn main() -> anyhow::Result<()> {
    let mut args = env::args();
    let _ = args.next();
    let file = args.next().ok_or_else(|| anyhow!("missing file name"))?;
    let contents = fs::read_to_string(&file).context("reading file")?;
    println!("{}", contents);
    Ok(())
}


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.

use std::env;

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len()!= 2 {
        println!("Usage: sum <file>");
        std::process::exit(1);
    }
    let filename = &args[1];
    if let Ok(lines) = std::fs::read_to_string(filename).map(Ok) {
        let numbers: Vec<i64> = lines.split_whitespace().map(|line| line.parse::<i64>().unwrap()).collect();
        let total: i64 = numbers.iter().filter(|&&n| n % 2 == 0).map(|&n| n * 2).sum();
        println!("{}", total);
    } else {
        println!("Unable to open file");
        std::process::exit(1);
    }
}


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.

fn main() {
    let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    let double = v.iter().map(|x| x * 2);
    let filtered = double.filter(|&x| x % 2 == 0);
    let sum = filtered.sum::<i32>();
    println!("{}", sum);
}


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.

use std::collections::HashMap;

fn main() {
    let mut map: HashMap<i32, i32> = HashMap::new();
    map.insert(0, 1);
    map.insert(1, 2);
    map.insert(2, 3);
    map.insert(3, 4);
    map.insert(4, 5);

    let sum = map.iter()
       .map(|(_k, v)| *v)
       .sum::<i32>();

    println!("The sum is: {}", sum);
}


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.

fn main() {
    let numbers = [1, 2, 3, 4, 5];

    let even_numbers = numbers.iter().filter(|&n| n % 2 == 0);
    let sum: u32 = even_numbers.map(|&n| n).sum();
    println!("{}", sum);
}


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.

use std::iter;

fn main() {
    let numbers = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    let double_numbers: Vec<i32> = numbers.iter().map(|x| x * 2).collect();
    let sum: i32 = double_numbers.iter().filter(|&x| x % 2 == 0).sum();
    println!("The sum is: {}", sum);
}


Prompt: Write only Rust code for a program that uses iterators with map/filter to compute a sum. Include `fn main()` and necessary imports. No explanations. Wrap code in ```rust code blocks.

fn main() {
    let values: Vec<u32> = vec![1, 2, 3, 4, 5];

    let sum = values
       .into_iter()
       .filter(|x| *x % 2 == 0)
       .map(|x| x + 1)
       .sum::<u32>();

    println!("Sum of even numbers: {}", sum);
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

use std::fmt;
use std::str::FromStr;

#[derive(Debug, Clone)]
pub struct U32x32([u8; 32]);

impl FromStr for U32x32 {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let mut bytes = [0u8; 32];
        for (i, byte) in s.bytes().zip(bytes.iter_mut()) {
            *byte = i;
        }
        Ok(U32x32(bytes))
    }
}

impl fmt::Display for U32x32 {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        for b in self.0.iter() {
            write!(f, "{}", b)?;
        }
        Ok(())
    }
}

fn main() {
    let input = "1234567890".parse::<U32x32>().unwrap();
    println!("{:?}", input);
    println!("{}", input);
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
struct U32Array(pub [u8; 32]);

impl FromStr for U32Array {
    type Err = std::num::ParseIntError;

    fn from_str(s: &str) -> Result<U32Array, Self::Err> {
        if s.len()!= 32 {
            return Err(std::num::ParseIntError);
        }

        let mut v = [0u8; 32];
        for (i, b) in s.bytes().enumerate() {
            v[i] = b;
        }

        Ok(U32Array(v))
    }
}

impl std::fmt::Display for U32Array {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        for &b in &self.0 {
            write!(f, "{b:02x}")?;
        }
        Ok(())
    }
}

fn main() {
    let s = "1234567890abcdef";
    let arr = U32Array::from_str(s).unwrap();
    println!("{:?}", arr);
    println!("{}", arr);
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

#[derive(Debug)]
struct BitVec([u8; 32]);

impl FromStr for BitVec {
    type Err = std::num::ParseIntError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        if s.len()!= 32 {
            Err(std::num::ParseIntError)
        } else {
            let mut bits = [0u8; 32];
            for (i, c) in s.chars().enumerate() {
                bits[i] = u8::from_str_radix(&c.to_string(), 2).unwrap();
            }
            Ok(Self(bits))
        }
    }
}

impl std::fmt::Display for BitVec {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        for bit in &self.0 {
            write!(f, "{}", bit)?;
        }
        Ok(())
    }
}

fn main() {
    let bit_vec = "1001001001010101001100000110001010101001000010000001010111101001001100100011011"
       .parse()
       .unwrap();
    println!("{:?}", bit_vec);
    println!("{}", bit_vec);
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

#[derive(Debug)]
pub struct PublicKey(pub [u8; 32]);

impl FromStr for PublicKey {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match hex::decode(&s) {
            Ok(pubkey) => match PublicKey(pubkey) {
                Ok(pubkey) => Ok(pubkey),
                Err(_) => Err("Invalid public key".to_string()),
            },
            Err(_) => Err("Invalid public key".to_string()),
        }
    }
}

impl std::fmt::Display for PublicKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut s = String::new();
        for byte in &self.0 {
            s.push_str(&format!("{:02x}", byte));
        }
        write!(f, "{}", s)
    }
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

use std::str::FromStr;
use std::fmt;

struct U8Array32([u8; 32]);

impl FromStr for U8Array32 {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let mut bytes = [0u8; 32];
        if s.len()!= 32 {
            return Err("String is too short to parse into 32 bytes".to_string());
        }
        for (i, byte) in bytes.iter_mut().enumerate() {
            *byte = u8::from_str(&s[i..i+1])?;
        }
        Ok(U8Array32(bytes))
    }
}

impl fmt::Display for U8Array32 {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut s = String::new();
        for byte in &self.0 {
            s.push_str(&byte.to_string());
        }
        write!(f, "{}", s)
    }
}

fn main() {
    let s = "hello world";
    let array = U8Array32::from_str(&s).unwrap();
    println!("{}", array);
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

use std::str::FromStr;

#[derive(Debug)]
struct Hash32([u8; 32]);

impl FromStr for Hash32 {
    type Err = std::num::ParseIntError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let mut bytes = [0u8; 32];
        let len = u32::from_str_radix(s, 16).map_err(|_| std::num::ParseIntError {})?;

        if len > 32 {
            return Err(std::num::ParseIntError {});
        }

        let mut i = 0;
        for c in s.as_bytes() {
            if i >= len {
                break;
            }
            bytes[i] = *c;
            i += 1;
        }

        Ok(Hash32(bytes))
    }
}

impl std::fmt::Display for Hash32 {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        for byte in &self.0 {
            write!(f, "{:02x}", byte)?;
        }

        Ok(())
    }
}

fn main() {
    let hash = "b3b4b5b6b7b8b9b0b1b2b3".parse::<Hash32>().unwrap();
    println!("{:?}", hash);
    println!("{}", hash);
}


Prompt: Define a newtype wrapper for [u8; 32] and implement FromStr and Display. Provide a small `fn main()` that parses and prints it. Output only Rust code in ```rust code blocks.

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
struct U32Array([u8; 32]);

impl FromStr for U32Array {
    type Err = std::num::ParseIntError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        if s.len()!= 32 {
            Err(std::num::ParseIntError::from("String must be 32 bytes"))
        } else {
            let mut array = [0u8; 32];
            for (i, c) in s.bytes().enumerate() {
                if c < 0x30 || c > 0x39 {
                    return Err(std::num::ParseIntError::from("Invalid character in string"));
                }
                array[i] = c - 0x30;
            }
            Ok(U32Array(array))
        }
    }
}

impl std::fmt::Display for U32Array {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        for &byte in &self.0 {
            write!(f, "{}", byte as char)?;
        }
        Ok(())
    }
}

fn main() {
    let a = U32Array::from_str("00000000000000000000000000000000").unwrap();
    println!("{:?}", a);
    println!("{}", a);
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

use thiserror::Error;
use std::io;

#[derive(Error, Debug)]
#[error("IO error: {0}")]
pub struct IOError(#[from] io::Error);

fn main() {
    let file = std::fs::File::open("file_does_not_exist.txt").map_err(IOError)?;
    let file = std::fs::File::open("file_does_not_exist.txt")?;
    println!("{:?}", file);
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

use thiserror::Error;

#[derive(thiserror::Error, Debug)]
pub enum MyError {
    #[error("An error with {0}")]
    Other(#[from] String),
}

fn run() -> Result<(), MyError> {
    let result = 2 + 2;
    let result = match result {
        4 => Ok(()),
        _ => Err(MyError::Other("result was not 4".to_string())),
    }?;
    Ok(())
}

fn main() {
    if let Err(e) = run() {
        println!("{:?}", e);
    }
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

// Define a custom error type using the `thiserror!` macro.
#[derive(thiserror::Error, Debug)]
pub enum MyError {
    #[error("Could not connect to server: {0}")]
    ServerConnection(String),
    #[error("Could not parse the response: {0}")]
    ParseError(String),
}

// Implement the `Display` trait to print out a custom message when the error is printed.
impl std::fmt::Display for MyError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{:?}", self)
    }
}

// Define a custom source type to be used as a cause of the error.
#[derive(Debug)]
pub struct Source {
    message: String,
}

impl Source {
    pub fn new(message: impl Into<String>) -> Self {
        Self {
            message: message.into(),
        }
    }
}

// Define a function using the `?` operator to propagate errors.
fn connect_to_server() -> Result<(), MyError> {
    let source = Source::new("Could not connect to server");
    Err(MyError::ServerConnection(source.message.clone()))
}

fn main() {
    if let Err(e) = connect_to_server() {
        println!("Error: {}", e);
    }
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

use thiserror::Error;

#[derive(Error, Debug)]
enum MyError {
    #[error("MyError: {0}")]
    MyError(String),
}

impl std::fmt::Display for MyError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::MyError(e) => write!(f, "MyError: {}", e),
        }
    }
}

fn main() {
    let result = do_something();
    match result {
        Ok(v) => println!("Success: {:?}", v),
        Err(e) => println!("Error: {}", e),
    }
}

fn do_something() -> Result<i32, MyError> {
    Err(MyError::MyError("Something went wrong".to_string()))
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

#[derive(thiserror::Error, Debug)]
enum MyError {
    #[error("invalid input")]
    InvalidInput(#[from] std::fmt::Error),
    #[error("invalid value: {0}")]
    InvalidValue(i32),
}

fn main() {
    match 1.1.parse::<i32>() {
        Ok(v) => println!("Parsed: {}", v),
        Err(e) => {
            if let MyError::InvalidInput(_) = e {
                println!("Input error");
            } else if let MyError::InvalidValue(v) = e {
                println!("Invalid value: {}", v);
            }
        }
    }
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

use thiserror::Error;

#[derive(Debug, Error, Display)]
enum MyError {
    #[error("not a number: {0}")]
    NotANumber(String),
    #[error("not a string")]
    NotAString,
    #[error("error with code: {0}")]
    CustomError(usize),
}

fn get_number(s: &str) -> Result<i32, MyError> {
    match s.parse::<i32>() {
        Ok(num) => Ok(num),
        Err(_) => Err(MyError::NotANumber(s.to_string())),
    }
}

fn get_string(s: &str) -> Result<String, MyError> {
    match s.to_string().as_str() {
        "test" => Ok("test".to_string()),
        _ => Err(MyError::NotAString),
    }
}

fn get_custom_error(s: &str) -> Result<(), MyError> {
    if s == "test" {
        Ok(())
    } else {
        Err(MyError::CustomError(10))
    }
}

fn main() {
    let num = get_number("test");
    println!("result: {:?}", num);

    let str = get_string("test");
    println!("result: {:?}", str);

    let error = get_custom_error("test");
    println!("result: {:?}", error);
}


Prompt: Create a small example showing a thiserror enum, Display, a source cause, and a function using the ? operator. Include `fn main()` to drive it. Output only Rust code wrapped in ```rust code blocks.

use thiserror::Error;

#[derive(Debug, thiserror)]
pub enum MyError {
    #[error("Could not open file: {0}")]
    FileOpen(std::io::Error),
    #[error("Could not read file: {0}")]
    FileRead(std::io::Error),
}

fn main() {
    let file = std::fs::File::open("non-existent-file.txt").unwrap();
    let result = std::io::Read::read_to_string(&file).map_err(MyError::FileRead).unwrap();
    println!("{}", result);
}


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

fn main() {
    // Import the necessary module
    use std::cmp::Ordering;

    // A list of numbers
    let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    // A for loop to print the numbers in ascending order
    for number in &numbers {
        match number.cmp(&5) {
            Ordering::Less => println!("{} is less than 5", number),
            Ordering::Equal => println!("{} is equal to 5", number),
            Ordering::Greater => println!("{} is greater than 5", number),
        }
    }

    // An if let statement to print the numbers greater than 5
    if let Some(number) = numbers.iter().find(|x| x > &5) {
        println!("The first number greater than 5 is {}", number);
    }

    // A match statement to print the sum of the numbers
    match numbers.iter().sum::<i32>() {
        0 => println!("The sum is 0"),
        _ => println!("The sum is not 0"),
    }
}


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

fn main() {
    let x = 1;

    // Matching with `match`
    match x {
        1 => println!("one"),
        2 => println!("two"),
        3 => println!("three"),
        _ => println!("anything"),
    }

    // Matching with `if let`
    if let Some(y) = Some(2) {
        println!("y = {}", y);
    }
}


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

fn main() {
    let a = 1;
    let b = "one";

    let c = 2;
    let d = "two";

    // Pattern matching with match
    match a {
        1 => println!("a is 1"),
        2 => println!("a is 2"),
        _ => println!("a is something else"),
    }

    // Pattern matching with if let
    if let 1 = a {
        println!("a is 1");
    } else {
        println!("a is not 1");
    }

    // Pattern matching with if let for reference
    let ref x = "one";
    if let Some(y) = x {
        println!("x is Some({})", y);
    } else {
        println!("x is None");
    }

    // Pattern matching with if let for reference with pattern binding
    if let Some(ref y) = x {
        println!("x is Some({})", y);
    } else {
        println!("x is None");
    }

    // Pattern matching with if let for tuple
    let (x, y) = (1, 2);
    if let (1, 2) = (x, y) {
        println!("x is 1 and y is 2");
    } else {
        println!("x is not 1 and y is not 2");
    }

    // Pattern matching with if let for tuple with pattern binding
    let (x, y) = (1, 2);
    if let (1, ref y) = (x, y) {
        println!("x is 1 and y is 2");
    } else {
        println!("x is not 1 and y is not 2");
    }

    // Pattern matching with match for tuple
    match (x, y) {
        (1, 2) => println!("x is 1 and y is 2"),
        (1, ref y) => println!("x is 1 and y is {}", y),
        _ => println!("x is not 1 and y is not 2"),
    }

    // Pattern matching with match for tuple with pattern binding
    let (x, y) = (1, 2);
    match (x, y) {
        (1, 2) => println!("x is 1 and y is 2"),
        (1, ref y) => println!("x is 1 and y is {}", y),
        _ => println!("x is not 1 and y is not 2"),
    }
}


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

fn main() {
    // let values to be matched
    let numbers = [1, 2, 3, 4, 5, 6];
    let numbers = vec![1, 2, 3, 4, 5, 6];

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }

    // match with tuple pattern
    match (1, 2, 3) {
        (1, 2, 3) => println!("one two three"),
        _ => println!("Not one two three"),
    }


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

// This is a simple Rust program that demonstrates how to use match and if let for pattern matching.
// It also shows the difference between the two.

// The program defines a few different types and then uses them in a few match and if let statements.

// The program prints the results of each match and if let to the console.

fn main() {
    // Define a variable of type String
    let s = "hello".to_string();

    // match with pattern matching
    match s.as_str() {
        "hello" => println!("hello"),
        "world" => println!("world"),
        _ => println!("unknown"),
    }

    // match with pattern matching and binding
    match s.as_str() {
        "hello" => println!("hello"),
        "world" => println!("world"),
        s => println!("unknown: {}", s),
    }

    // if let with pattern matching and binding
    if let "hello" = s.as_str() {
        println!("hello");
    } else if let "world" = s.as_str() {
        println!("world");
    } else {
        println!("unknown");
    }

    // if let with pattern matching and binding
    if let Some(s) = s.as_str().strip_suffix("o") {
        println!("{}o", s);
    } else {
        println!("no o");
    }
}


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

fn main() {
    let a = 1;
    let b = 2;
    let c = 3;
    let d = 4;

    // pattern matching with if let
    if let 1 = a {
        println!("a is 1");
    } else if let 2 = b {
        println!("b is 2");
    } else {
        println!("a and b are not 1 or 2");
    }

    // pattern matching with match
    match a {
        1 => println!("a is 1"),
        2 => println!("a is 2"),
        3 => println!("a is 3"),
        _ => println!("a is not 1, 2 or 3"),
    }

    // pattern matching with match
    match d {
        1 | 2 => println!("d is 1 or 2"),
        3 => println!("d is 3"),
        4 => println!("d is 4"),
        _ => println!("d is not 1, 2, 3 or 4"),
    }
}


Prompt: Write a complete Rust program with `fn main()` that demonstrates pattern matching with `match` and `if let`. Include necessary imports. Output only code in ```rust code blocks.

use std::cmp::Ordering;

fn main() {
    // match statement
    let number = 5;
    match number {
        1 => println!("One"),
        2 => println!("Two"),
        3 => println!("Three"),
        _ => println!("A generic value"),
    }

    // if let statement
    let number = 4;
    if let 1 = number {
        println!("One");
    } else {
        println!("Not One");
    }

    // let pattern
    let number = Some(3);
    if let Some(3) = number {
        println!("Three");
    }

    // let pattern with destructuring
    let point = (3, 4);
    match point {
        (0, 0) => println!("Origin"),
        (0, y) => println!("On the y-axis at y = {}", y),
        (x, 0) => println!("On the x-axis at x = {}", x),
        (x, y) => println!("On the x-axis at x = {}, on the y-axis at y = {}", x, y),
    }

    // let pattern with tuple structs
    let point = (0, 0, 0);
    match point {
        (0, 0, 0) => println!("Origin"),
        (0, 0, y) => println!("On the z-axis at z = {}", y),
        (0, x, 0) => println!("On the x-axis at x = {}", x),
        (x, 0, 0) => println!("On the y-axis at y = {}", x),
        (x, y, z) => println!("On the x-axis at x = {}, on the y-axis at y = {}, on the z-axis at z = {}", x, y, z),
    }

    // let pattern with enum
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        Color::Green => println!("The color is green"),
        Color::Red => println!("The color is red"),
    }

    // let pattern with enum and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        Color::Green => println!("The color is green"),
        Color::Red => println!("The color is red"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with wildcard
    let color = Color::Blue;
    match color {
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }

    // let pattern with tuple and wildcard
    let color = Color::Blue;
    match color {
        Color::Blue => println!("The color is blue"),
        _ => println!("The color is not blue"),
    }


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

// Define a struct Person
struct Person {
    name: String,
    age: i32,
}

// Define an impl block for Person
impl Person {
    // Constructor
    fn new(name: String, age: i32) -> Self {
        Self { name, age }
    }

    // Method to print the person's details
    fn print_details(&self) {
        println!("Name: {}", self.name);
        println!("Age: {}", self.age);
    }
}

// Define a trait Animal
trait Animal {
    fn sound(&self);
}

// Implement the trait Animal for Person
impl Animal for Person {
    fn sound(&self) {
        println!("BEEP");
    }
}

fn main() {
    // Create a Person instance
    let person = Person::new("John".to_string(), 30);

    // Call the constructor method
    let person2 = Person::new("Jane".to_string(), 30);

    // Call the print_details method
    person.print_details();

    // Call the sound method
    person.sound();
}


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

struct Circle {
    radius: f64,
}

impl Circle {
    pub fn new(radius: f64) -> Circle {
        Circle { radius }
    }

    pub fn area(&self) -> f64 {
        self.radius * self.radius * std::f64::consts::PI
    }
}

trait Shape {
    fn get_area(&self) -> f64;
}

impl Shape for Circle {
    fn get_area(&self) -> f64 {
        self.area()
    }
}

fn main() {
    let c = Circle::new(5.0);
    let area = c.get_area();
    println!("The area of the circle is {}", area);
}


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

// Define a struct
struct Person {
    name: String,
    age: u8,
}

// Implement a trait for the struct
impl Person {
    // Constructor
    pub fn new(name: String, age: u8) -> Self {
        Person { name, age }
    }

    // Method
    pub fn greet(&self) {
        println!("Hello, my name is {} and I am {} years old.", self.name, self.age);
    }
}

// Trait
trait Animal {
    fn speak(&self) -> String;
}

// Implement the trait for the struct
impl Animal for Person {
    fn speak(&self) -> String {
        "Hello, how are you?".to_string()
    }
}

fn main() {
    // Create an instance of the struct
    let person = Person::new("John".to_string(), 25);

    // Use the trait method
    println!("{}", person.speak());

    // Use the method on the struct
    person.greet();
}


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

struct Point {
    x: i32,
    y: i32,
}

impl Point {
    fn new(x: i32, y: i32) -> Self {
        Point { x, y }
    }
}

trait Shape {
    fn area(&self) -> i32;
    fn perimeter(&self) -> i32;
}

impl Shape for Point {
    fn area(&self) -> i32 {
        self.x * self.y
    }

    fn perimeter(&self) -> i32 {
        2 * (self.x + self.y)
    }
}

fn main() {
    let p1 = Point::new(3, 5);
    println!("Area: {}", p1.area());
    println!("Perimeter: {}", p1.perimeter());
}


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

struct Person {
    name: String,
    age: u32,
}

impl Person {
    fn new(name: String, age: u32) -> Self {
        Self { name, age }
    }
}

trait Greeting {
    fn greet(&self) -> String;
}

impl Greeting for Person {
    fn greet(&self) -> String {
        format!("Hello, my name is {} and I am {} years old", self.name, self.age)
    }
}

fn main() {
    let person = Person::new("Alice".to_string(), 30);
    println!("{}", person.greet());
}


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

// Define a trait for the data to be printed
trait Printable {
    fn print(&self);
}

// Define a struct to hold the data to be printed
struct Data {
    name: String,
    age: i32,
}

// Implement the trait for the struct
impl Printable for Data {
    // Implement the `print` function for the struct
    fn print(&self) {
        println!("Name: {}", self.name);
        println!("Age: {}", self.age);
    }
}

// Define the main function
fn main() {
    // Create an instance of the struct
    let data = Data {
        name: "John".to_string(),
        age: 25,
    };

    // Use the `print` function to print the data
    data.print();
}


Prompt: Create a Rust program with a struct, an impl block, and a trait implementation. Include `fn main()` to demonstrate usage. Output only code in ```rust code blocks.

// Define a trait
trait HasArea {
    fn area(&self) -> f64;
}

// Define a struct
struct Rectangle {
    width: f64,
    height: f64,
}

// Implement the trait for Rectangle
impl HasArea for Rectangle {
    fn area(&self) -> f64 {
        self.width * self.height
    }
}

fn main() {
    // Create an instance of Rectangle
    let r = Rectangle { width: 2.0, height: 4.0 };

    // Use the trait method
    let area = r.area();

    println!("The area of the rectangle is {}", area);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct User {
    username: String,
    email: String,
    age: u8,
}

fn main() {
    let user = User {
        username: "johndoe".to_string(),
        email: "johndoe@example.com".to_string(),
        age: 32,
    };

    let user_json = serde_json::to_string(&user).unwrap();
    println!("User in JSON format: {}", user_json);

    let deserialized_user: User = serde_json::from_str(&user_json).unwrap();
    println!("Deserialized User: {:?}", deserialized_user);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct User {
    name: String,
    age: u8,
}

fn main() {
    let user = User {
        name: "John".to_string(),
        age: 30,
    };

    let json = serde_json::to_string(&user).unwrap();
    println!("Serialized: {}", json);

    let user: User = serde_json::from_str(&json).unwrap();
    println!("Deserialized: {:?}", user);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct Person {
    name: String,
    age: u8,
    friends: Vec<String>,
}

fn main() {
    let person = Person {
        name: "John".to_string(),
        age: 25,
        friends: vec!["Alice".to_string(), "Bob".to_string()],
    };

    let serialized = serde_json::to_string(&person).unwrap();
    println!("Serialized JSON: {}", serialized);

    let deserialized: Person = serde_json::from_str(&serialized).unwrap();
    println!("Deserialized JSON: {:?}", deserialized);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
struct Person {
    name: String,
    age: u8,
}

fn main() {
    let person = Person {
        name: "John".to_string(),
        age: 30,
    };

    let serialized = serde_json::to_string(&person).unwrap();
    println!("serialized JSON: {}", serialized);

    let deserialized: Person = serde_json::from_str(&serialized).unwrap();
    println!("deserialized: {:?}", deserialized);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

#[macro_use]
extern crate serde_derive;
extern crate serde_json;

use serde_json::to_string_pretty;

#[derive(Debug, Serialize, Deserialize)]
struct Person {
    first_name: String,
    last_name: String,
    age: u8,
}

fn main() {
    let mut person = Person {
        first_name: "John".to_string(),
        last_name: "Doe".to_string(),
        age: 20,
    };

    println!("Person: {:?}", person);

    let json = to_string_pretty(&person).unwrap();
    println!("JSON: {}", json);

    let new_person: Person = serde_json::from_str(&json).unwrap();
    println!("New Person: {:?}", new_person);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct User {
    id: u32,
    name: String,
    age: u8,
}

fn main() {
    let user = User {
        id: 1,
        name: "John".to_string(),
        age: 30,
    };

    let json = serde_json::to_string(&user).unwrap();
    println!("JSON: {}", json);

    let deserialized: User = serde_json::from_str(&json).unwrap();
    println!("Deserialized User: {:?}", deserialized);
}


Prompt: Write a Rust program that uses serde to serialize and deserialize a struct to JSON. Include `fn main()` and use serde_json. Output only Rust code in ```rust code blocks.

#[derive(Debug, Serialize, Deserialize)]
struct Person {
    name: String,
    age: u8,
}

fn main() {
    let person = Person {
        name: "John".to_string(),
        age: 30,
    };

    let json = serde_json::to_string(&person).unwrap();
    println!("JSON: {}", json);

    let deserialized_person: Person = serde_json::from_str(&json).unwrap();
    println!("Deserialized: {:?}", deserialized_person);
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    // Example text
    let text = "The quick brown fox jumps over the lazy dog.";

    // Replace 'o' with '0'
    let re = Regex::new("o").unwrap();
    let text = re.replace_all(&text, "0").to_string();

    println!("Original text: {}", text);
    println!("Replaced text: {}", text.replace("0", "o"));
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    let mut text = "The quick brown fox jumps over the lazy dog. Foxes are quick animals.";

    let re = Regex::new("fox").unwrap();
    let new_text = re.replace_all(&text, "cat");

    println!("{}", new_text);
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    let re = Regex::new(r"\b\w+\b").unwrap();
    let text = "The quick brown fox jumps over the lazy dog. The dog barks at the fox.";
    let text = re.replace_all(&text, "<word>");
    println!("{}", text);
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    let text = "This is a test string with multiple words. It should be replaced.";
    let pattern = Regex::new(r"\btest\b").unwrap();
    let replaced = pattern.replace_all(&text, "replaced");

    println!("{}", replaced);
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    // Example text
    let text = "This is a sample text with some 1, 2, 3 and 4 digits.";

    // Regular expression pattern
    let pattern = Regex::new(r"(\d+)").unwrap();
    let replacement = "x";

    // Replace all occurrences of 1, 2, 3 and 4 digits with "x"
    let new_text = pattern.replace_all(&text, &replacement);

    // Print the result
    println!("{}", new_text);
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    let pattern = "abc";
    let text = "abc abc abc";
    let re = Regex::new(pattern).unwrap();
    let text = re.replace_all(&text, "def");
    println!("{}", text);
}


Prompt: Create a Rust program that uses the regex crate to find and replace patterns in a string. Include `fn main()` with example text. Output only Rust code in ```rust code blocks.

use regex::Regex;

fn main() {
    let text = "My email address is john.doe@example.com and my phone number is 123-456-7890.";
    let re = Regex::new(r"(\d{3}-\d{3}-\d{4})").unwrap();
    let replacement = "XXX-XXX-XXXX";
    let new_text = re.replace_all(&text, replacement).to_string();
    println!("{}", new_text);
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

use chrono::{DateTime, Utc};

fn main() {
    let date_string = "2015-01-01 00:00:00";
    let date = DateTime::parse_from_rfc3339(date_string).unwrap();
    let formatted = date.format("%A, %b %e, %Y").to_string();
    println!("Date: {}", formatted);

    let date_string = "2015-01-01T00:00:00+00:00";
    let date = DateTime::parse_from_rfc3339(date_string).unwrap();
    let formatted = date.format("%A, %b %e, %Y").to_string();
    println!("Date: {}", formatted);
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

use chrono::NaiveDateTime;
use chrono::offset::TimeZone;
use chrono::offset::Utc;
use chrono::offset::TimeZone;
use chrono::Local;

fn main() {
    // Using Utc
    let date = "2022-12-25 14:00:00";
    let parsed_date = NaiveDateTime::parse_from_str(date, "%Y-%m-%d %H:%M:%S").unwrap();
    let formatted_date = Utc.from_utc_datetime(&parsed_date).format("%B %d, %Y");
    println!("Using Utc: {}", formatted_date);

    // Using Local
    let date = "2022-12-25 14:00:00";
    let parsed_date = NaiveDateTime::parse_from_str(date, "%Y-%m-%d %H:%M:%S").unwrap();
    let formatted_date = Local.from_utc_datetime(&parsed_date).format("%B %d, %Y");
    println!("Using Local: {}", formatted_date);
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

use chrono::{DateTime, NaiveDateTime, ParseError, Utc};

fn parse_and_format(s: &str) -> Result<String, ParseError> {
    let dt: DateTime<Utc> = s.parse()?;
    Ok(dt.to_rfc3339())
}

fn main() {
    let mut vec: Vec<String> = Vec::new();

    vec.push(parse_and_format("2022-01-01").unwrap());
    vec.push(parse_and_format("2022-01-01T00:00:00").unwrap());
    vec.push(parse_and_format("2022-01-01T00:00:00.000000").unwrap());
    vec.push(parse_and_format("2022-01-01T00:00:00.000001").unwrap());
    vec.push(parse_and_format("2022-01-01T00:00:00.123456").unwrap());
    vec.push(parse_and_format("2022-01-01T00:00:00.123456789").unwrap());
    vec.push(parse_and_format("2022-01-01T00:00:00.123456789012").unwrap());

    for s in vec {
        println!("{}", s);
    }
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

use chrono::format::{self, ItemFormatSpecifier};

fn main() {
    let date_str = "2021-07-07 13:37:27";
    let date = date_str.parse::<chrono::NaiveDateTime>().unwrap();

    // Parse date with time zone
    let date_with_tz = date.with_timezone(&chrono::offset::Local);
    let parsed_date = date_str.parse::<chrono::NaiveDateTime>().unwrap();
    println!("Parsed date with time zone: {:?}", parsed_date.with_timezone(&chrono::offset::Local));

    // Parse date and time
    let parsed_date_time = date_str.parse::<chrono::NaiveDateTime>().unwrap();
    println!("Parsed date and time: {:?}", parsed_date_time);

    // Parse date and time with time zone
    let parsed_date_time_with_tz = date_str.parse::<chrono::NaiveDateTime>().unwrap();
    println!("Parsed date and time with time zone: {:?}", parsed_date_time_with_tz.with_timezone(&chrono::offset::Local));

    // Format date with time zone
    let formatted_date = date_with_tz.format("%a, %b %d %Y %H:%M:%S %Z%z").to_string();
    println!("Formatted date with time zone: {}", formatted_date);

    // Format date and time
    let formatted_date_time = parsed_date_time.format("%a, %b %d %Y %H:%M:%S %Z%z").to_string();
    println!("Formatted date and time: {}", formatted_date_time);

    // Format date and time with time zone
    let formatted_date_time_with_tz = parsed_date_time_with_tz.format("%a, %b %d %Y %H:%M:%S %Z%z").to_string();
    println!("Formatted date and time with time zone: {}", formatted_date_time_with_tz);
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

extern crate chrono;

fn main() {
    let date = "1978-11-25".parse::<chrono::NaiveDateTime>().unwrap();
    let formatted = date.format("%a, %B %e, %Y").to_string();
    println!("Parsed date: {:?}", date);
    println!("Formatted date: {}", formatted);

    let date = "2020-05-15".parse::<chrono::NaiveDateTime>().unwrap();
    let formatted = date.format("%a, %B %e, %Y").to_string();
    println!("Parsed date: {:?}", date);
    println!("Formatted date: {}", formatted);
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

use chrono::prelude::*;

fn main() {
    let date = DateTime::parse_from_rfc2822("Wed, 15 Apr 2020 12:30:30 +0000").unwrap();
    println!("Date: {}", date);

    let date = DateTime::parse_from_rfc2822("Wed, 15 Apr 2020 12:30:30 +0000").unwrap();
    println!("Date: {}", date.format("%Y-%m-%d %H:%M:%S%z"));

    let date = DateTime::parse_from_rfc2822("Wed, 15 Apr 2020 12:30:30 +0000").unwrap();
    println!("Date: {}", date.format("%A, %B %d %Y %H:%M:%S%z"));

    let date = DateTime::parse_from_rfc2822("Wed, 15 Apr 2020 12:30:30 +0000").unwrap();
    println!("Date: {}", date.format("%A, %B %d %Y %H:%M:%S%z"));

    let date = DateTime::parse_from_rfc2822("Wed, 15 Apr 2020 12:30:30 +0000").unwrap();
    println!("Date: {}", date.format("%a %b %e %H:%M:%S%z"));
}


Prompt: Write a Rust program that uses chrono to parse a date string and format it differently. Include `fn main()` with example dates. Output only Rust code in ```rust code blocks.

use chrono::NaiveDateTime;
use chrono::NaiveDate;
use chrono::NaiveTime;

fn main() {
    let date = NaiveDate::from_ymd(2020, 12, 1);
    let time = NaiveTime::from_hms(14, 10, 30);
    let datetime = NaiveDateTime::new(date, time);

    // Format to "2020-12-01 14:10:30"
    println!("{}", datetime);

    // Format to "2020-12-01 14:10"
    println!("{}", datetime.with_time(0));

    // Format to "2020-12-01 14:10:30 UTC"
    println!("{}", datetime.with_timezone(&chrono::Utc));

    // Format to "2020-12-01 14:10:30 +00:00"
    println!("{}", datetime.with_timezone(&chrono::TimeZone::offset(0)));

    // Format to "2020-12-01"
    println!("{}", datetime.date());

    // Format to "2020-12-01 14:10:30"
    println!("{}", datetime.time());

    // Format to "2020-12-01 14:10:30 +00:00"
    println!("{}", datetime.with_timezone(&chrono::FixedOffset::east(0)).to_string());

    // Format to "2020-12-01 14:10:30 +00:00"
    println!("{}", datetime.with_timezone(&chrono::FixedOffset::east(0)).to_string());

    // Format to "2020-12-01 14:10:30"
    println!("{}", datetime.with_timezone(&chrono::FixedOffset::east(0)).format("%Y-%m-%d %H:%M:%S"));
}


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.

use uuid::Uuid;

fn main() {
    // Generate a random UUID
    let random_uuid = Uuid::new_v4();
    println!("Random UUID: {:?}", random_uuid);

    // Generate a random UUID with a fixed node and clock sequence
    let fixed_uuid = Uuid::new_v4_with_timestamp_and_clock_sequence(0, 0);
    println!("Fixed UUID: {:?}", fixed_uuid);

    // Generate a random UUID from a slice of bytes
    let bytes: [u8; 16] = [0u8; 16];
    let uuid_from_bytes = Uuid::from_bytes(bytes);
    println!("UUID from bytes: {:?}", uuid_from_bytes);

    // Generate a random UUID from a slice of bytes with a fixed node
    let bytes: [u8; 16] = [0u8; 16];
    let uuid_from_bytes_with_node = Uuid::from_bytes_with_node(bytes, 0);
    println!("UUID from bytes with node: {:?}", uuid_from_bytes_with_node);

    // Generate a random UUID from a string
    let uuid_from_string = Uuid::parse_str("6f2c3a1a-0dcd-4e7f-8b6d-7b1b7c8d9e0f");
    println!("UUID from string: {:?}", uuid_from_string);

    // Generate a random UUID from a string with a fixed node
    let uuid_from_string_with_node = Uuid::parse_str_with_node("6f2c3a1a-0dcd-4e7f-8b6d-7b1b7c8d9e0f", 0);
    println!("UUID from string with node: {:?}", uuid_from_string_with_node);
}


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.

use uuid::Uuid;

fn main() {
    // Generate a random UUID
    let random_uuid = Uuid::new_v4();
    println!("Random UUID: {}", random_uuid);

    // Generate a random UUID with a specific version
    let random_uuid = Uuid::new_v4().is_version(1);
    println!("Random UUID v1: {}", random_uuid);

    // Generate a random UUID with a specific version and node
    let random_uuid = Uuid::new_v4().is_version(1).with_node("some-node");
    println!("Random UUID v1 with node: {}", random_uuid);

    // Generate a random UUID with a specific version, node, and clock sequence
    let random_uuid = Uuid::new_v4()
       .is_version(1)
       .with_node("some-node")
       .with_clock_seq(42);
    println!("Random UUID v1 with node and clock sequence: {}", random_uuid);

    // Generate a random UUID from a string
    let random_uuid = Uuid::parse_str("f3c6e3d6-8a99-4cfa-9e0a-4d2f4b9c6d65");
    println!("Parsed UUID: {}", random_uuid);

    // Generate a random UUID from a string with a specific version
    let random_uuid = Uuid::parse_str("f3c6e3d6-8a99-4cfa-9e0a-4d2f4b9c6d65").is_version(1);
    println!("Parsed UUID v1: {}", random_uuid);

    // Generate a random UUID from a string with a specific version and node
    let random_uuid = Uuid::parse_str("f3c6e3d6-8a99-4cfa-9e0a-4d2f4b9c6d65")
       .is_version(1)
       .with_node("some-node");
    println!("Parsed UUID v1 with node: {}", random_uuid);

    // Generate a random UUID from a string with a specific version, node, and clock sequence
    let random_uuid = Uuid::parse_str("f3c6e3d6-8a99-4cfa-9e0a-4d2f4b9c6d65")
       .is_version(1)
       .with_node("some-node")
       .with_clock_seq(42);
    println!("Parsed UUID v1 with node and clock sequence: {}", random_uuid);
}


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.

use uuid::Uuid;

fn main() {
    let uuid = Uuid::new_v4();
    println!("new_v4: {}", uuid);

    let uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, "rust-lang.org");
    println!("new_v5: {}", uuid);

    let uuid = Uuid::parse_str("7f9c2f8a-3c1b-4d0f-8d0c-1d3d8f1e8b8d");
    println!("parse_str: {:?}", uuid);

    let uuid = Uuid::parse_str("invalid-uuid");
    match uuid {
        Ok(uuid) => println!("parse_str: {:?}", uuid),
        Err(_) => println!("parse_str: Invalid UUID")
    }

    let uuid = Uuid::parse_str("7f9c2f8a-3c1b-4d0f-8d0c-1d3d8f1e8b8d");
    println!("parse_str: {:?}", uuid);

    let uuid = Uuid::parse_str("invalid-uuid");
    match uuid {
        Ok(uuid) => println!("parse_str: {:?}", uuid),
        Err(_) => println!("parse_str: Invalid UUID")
    }

    let uuid = Uuid::parse_str("7f9c2f8a-3c1b-4d0f-8d0c-1d3d8f1e8b8d");
    println!("parse_str: {:?}", uuid);

    let uuid = Uuid::parse_str("invalid-uuid");
    match uuid {
        Ok(uuid) => println!("parse_str: {:?}", uuid),
        Err(_) => println!("parse_str: Invalid UUID")
    }
}


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.

use uuid::Uuid;

fn main() {
    let id = Uuid::new_v4();
    println!("Random UUID: {}", id);
    let id = Uuid::new_v5(Uuid::NAMESPACE_URL, "https://www.rust-lang.org/");
    println!("UUID from URL: {}", id);
    let id = Uuid::parse_str("c7c7f6c6-9fdd-4b1f-8e9f-b0e8c5b5f7f6");
    match id {
        Ok(id) => println!("Parsed UUID: {}", id),
        Err(e) => println!("Error: {}", e),
    }
}


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.

use uuid::Uuid;

fn main() {
    println!("{}", Uuid::new_v4());
    println!("{}", Uuid::parse_str("2f9b9e3f-7b8c-4f0b-b2b8-1a4b7a0b4b7a").unwrap());
    let a = Uuid::parse_str("2f9b9e3f-7b8c-4f0b-b2b8-1a4b7a0b4b7a").unwrap();
    println!("{}", a);
    let b = Uuid::parse_str("2f9b9e3f-7b8c-4f0b-b2b8-1a4b7a0b4b7a").unwrap();
    println!("{}", b);
    println!("{}", Uuid::new_v4());
    let c = Uuid::new_v4();
    println!("{}", c);
    println!("{}", c);
}


Prompt: Create a Rust program that generates UUIDs using the uuid crate. Include `fn main()` that generates and prints multiple UUIDs. Output only Rust code in ```rust code blocks.

extern crate uuid;

use uuid::Uuid;

fn main() {
    // Generate a random UUID
    let random_uuid = Uuid::new_v4();
    println!("Random UUID: {:?}", random_uuid);

    // Generate a random UUID from a specific variant
    let random_uuid_v5 = Uuid::new_v5(Uuid::NAMESPACE_DNS, "example.com");
    println!("Random UUID (v5): {:?}", random_uuid_v5);

    // Generate a random UUID from a specific namespace
    let random_uuid_ns = Uuid::new_v4();
    println!("Random UUID from Namespace: {:?}", random_uuid_ns);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::Rng;

fn main() {
    let mut rng = rand::thread_rng();
    let v: Vec<i32> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    let random_item: i32 = rng.gen_range(0, 10);
    let random_item = v[random_item as usize];

    println!("Random item: {}", random_item);

    let random_item: i32 = rng.gen_range(0, 10);
    let random_item = v[random_item as usize];

    println!("Random item: {}", random_item);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::prelude::*;
use rand::distributions::Alphanumeric;
use rand::Rng;

fn main() {
    let mut rng = thread_rng();
    let random_number: u32 = rng.gen_range(0..100);
    let mut random_char = String::new();
    for _ in 0..random_number {
        random_char.push(rng.sample(Alphanumeric));
    }

    println!("Random number: {}", random_number);
    println!("Random char: {}", random_char);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::Rng;
use rand::distributions::{Distribution, Range};
use rand::prelude::*;

fn main() {
    // Generate a random number between 0 and 10
    let mut rng = rand::thread_rng();
    let random_number: u32 = rng.gen_range(0..10);
    println!("Random number: {}", random_number);

    // Create a vector
    let mut numbers: Vec<u32> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    println!("Random numbers: {:?}", numbers);

    // Select a random number from the vector
    let random_number_from_vec: u32 = numbers
       .iter()
       .choose(&mut rng)
       .unwrap()
       .clone();

    println!("Random number from vector: {}", random_number_from_vec);

    // Select a random number from 0 to 10
    let random_number_from_range: u32 = rng.sample(Range::new(0, 10));

    println!("Random number from range: {}", random_number_from_range);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::prelude::*;

fn main() {
    // create a vector of numbers
    let numbers = vec![1, 2, 3, 4, 5];

    // get a random number from 0 to 4
    let mut rng = thread_rng();
    let random_index = rng.gen_range(0..5);

    // select a random number from the vector
    let random_number = numbers[random_index];

    println!("Random number: {}", random_number);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::prelude::*;

fn main() {
    let mut rng = thread_rng();
    let my_vec = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];

    println!("Random number: {}", rng.gen::<i32>());
    println!("Random number between 1 and 100: {}", rng.gen_range(1..=100));

    let random_element: i32 = rng.gen_range(0..my_vec.len());
    println!("Random element: {}", my_vec[random_element as usize]);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::Rng;

fn main() {
    let mut rng = rand::thread_rng();
    let mut numbers: Vec<u32> = Vec::new();
    for _ in 0..10 {
        numbers.push(rng.gen_range(0, 100));
    }
    let max = *numbers.iter().max().unwrap();
    let min = *numbers.iter().min().unwrap();
    let range: u32 = rng.gen_range(min..=max);
    println!("Random number in range: {}", range);
    let mut numbers = vec![1, 2, 3, 4, 5];
    let random_item = &numbers[rng.gen_range(0..numbers.len())];
    println!("Random item: {}", random_item);
}


Prompt: Write a Rust program that uses the rand crate to generate random numbers and select random items from a vector. Include `fn main()`. Output only Rust code in ```rust code blocks.

use rand::prelude::*;

fn main() {
    let mut rng = thread_rng();
    let mut items = vec!["apple", "banana", "orange", "grape", "strawberry"];
    let random_item = items.choose(&mut rng);
    println!("{}", random_item.unwrap());
}