Superuser666-Sigil commited on
Commit
ace684d
·
verified ·
1 Parent(s): d8166ad

Upload checkpoint-4000 evaluation samples

Browse files
Files changed (1) hide show
  1. checkpoint-4000/samples.jsonl +77 -0
checkpoint-4000/samples.jsonl ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"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.", "gen": "use anyhow::Result;\n\nfn main() -> Result<()> {\n let a = std::fs::File::open(\"nonexistant\")?;\n let _ = a.metadata()?;\n Ok(())\n}"}
2
+ {"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.", "gen": "use anyhow::{anyhow, Result};\n\nfn main() -> anyhow::Result<()> {\n let a: u8 = \"not a number\".parse()?;\n Ok(())\n}"}
3
+ {"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.", "gen": "use anyhow::{anyhow, Context, Result};\n\nfn main() -> anyhow::Result<()> {\n let x = std::fs::read(\"no_file\")?;\n Ok(())\n}"}
4
+ {"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.", "gen": "use anyhow::{Context, Result};\nuse std::fs::File;\n\nfn main() -> Result<()> {\n let file = File::open(\"test.txt\").context(\"could not open file\")?;\n Ok(())\n}"}
5
+ {"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.", "gen": "use anyhow::{bail, Context, Result};\n\nfn main() -> Result<()> {\n let err = \"Error\".to_string();\n let err2 = \"Another error\".to_string();\n let res = \"Result\".to_string();\n\n match 1 + 1 {\n 1 => bail!(err),\n _ => Ok(()),\n }?;\n\n Ok(())\n}"}
6
+ {"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.", "gen": "use anyhow::{anyhow, Result};\nuse std::convert::TryInto;"}
7
+ {"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.", "gen": "use anyhow::{anyhow, Context, Result};\nuse std::path::PathBuf;\n\nfn main() -> anyhow::Result<()> {\n let path = PathBuf::from(\"/tmp/file.txt\");\n let file = std::fs::File::open(path).context(\"Failed to open file\")?;\n let _ = file.read_to_string().context(\"Failed to read file\")?;\n Ok(())\n}"}
8
+ {"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.", "gen": "fn main() {\n let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n let even_numbers = &numbers.iter().filter(|&x| x % 2 == 0);\n let sum = even_numbers.clone().fold(0, |sum, x| sum + x);\n println!(\"Sum of even numbers: {}\", sum);\n}"}
9
+ {"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.", "gen": "fn main() {\n let numbers = vec![1, 2, 3, 4, 5, 6];\n let squares = numbers\n .into_iter()\n .map(|n| n * n)\n .filter(|n| *n % 2 == 0)\n .collect::<Vec<i32>>();\n println!(\"{:?}\", squares);\n}"}
10
+ {"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.", "gen": "use std::collections::HashMap;\n\nfn main() {\n let mut map = HashMap::new();\n map.insert(\"a\", 1);\n map.insert(\"b\", 2);\n map.insert(\"c\", 3);\n\n let total = map.values().filter(|v| **v > 1).map(|v| v + 1).sum();\n\n println!(\"total: {}\", total);\n}"}
11
+ {"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.", "gen": "use std::env;\nuse std::process;\n\nfn main() {\n let args: Vec<String> = env::args().collect();\n\n if args.len()!= 2 {\n eprintln!(\"Usage: {} <file>\", args[0]);\n process::exit(1);\n }\n\n let filename = &args[1];\n\n let mut sum = 0;\n\n if let Ok(file) = std::fs::File::open(filename) {\n let reader = std::io::BufReader::new(file);\n let lines = reader.lines().filter_map(|line| line.ok());\n\n for line in lines {\n let n = line.parse::<i32>().ok();\n if let Some(n) = n {\n sum += n;\n }\n }\n } else {\n eprintln!(\"Couldn't open file\");\n process::exit(1);\n }\n\n println!(\"{}\", sum);\n}"}
12
+ {"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.", "gen": "fn main() {\n let numbers = vec![1, 2, 3, 4, 5];\n let double_numbers = numbers.iter().map(|x| x * 2).collect::<Vec<i32>>();\n let even_numbers = double_numbers.iter().filter(|&x| x % 2 == 0).collect::<Vec<i32>>();\n let sum = even_numbers.iter().sum::<i32>();\n println!(\"Sum: {}\", sum);\n}"}
13
+ {"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.", "gen": "use std::iter;\nuse std::ops::RangeInclusive;\n\nfn main() {\n let a: Vec<i32> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n let b: Vec<i32> = (1..=10).collect();\n\n let sum_a: i32 = a.iter().filter(|&x| x % 2 == 0).sum();\n let sum_b: i32 = b.filter(|x| *x % 2 == 0).sum();\n\n assert_eq!(sum_a, sum_b);\n}"}
14
+ {"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.", "gen": "fn main() {\n let numbers = vec![1, 2, 3, 4, 5];\n let even = numbers.iter().filter(|&x| x % 2 == 0);\n let sum = even.clone().map(|x| x * 2).sum::<i32>();\n println!(\"Sum of even numbers: {}\", sum);\n}"}
15
+ {"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.", "gen": "struct Secret([u8; 32]);\n\nimpl std::str::FromStr for Secret {\n type Err = std::num::ParseIntError;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n let mut bytes = [0; 32];\n let len = s\n .as_bytes()\n .iter()\n .zip(bytes.iter_mut())\n .try_for_each(|(b, b)| *b = *b)?;\n\n Ok(Self(bytes))\n }\n}\n\nimpl std::fmt::Display for Secret {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n for byte in self.0.iter() {\n write!(f, \"{:02x}\", byte)?;\n }\n Ok(())\n }\n}\n\nfn main() {\n let secret = Secret::from_str(\"1234567890abcdef01234567890abcdef\").unwrap();\n println!(\"{}\", secret);\n}"}
16
+ {"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.", "gen": "#[derive(Debug, PartialEq, Eq, Clone, Copy)]\npub struct Hash32(pub [u8; 32]);"}
17
+ {"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.", "gen": "use std::str::FromStr;\nuse std::fmt;\n\nnewtype MyVec([u8; 32]);\n\nimpl FromStr for MyVec {\n type Err = String;\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n let mut vec = [0; 32];\n if s.len()!= 32 {\n return Err(\"Input string is not 32 bytes long\".to_string());\n }\n for (i, c) in s.chars().enumerate() {\n vec[i] = c as u8;\n }\n Ok(MyVec(vec))\n }\n}\n\nimpl fmt::Display for MyVec {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n for i in 0..32 {\n write!(f, \"{}\", self.0[i] as char)?;\n }\n Ok(())\n }\n}\n\nfn main() {\n let s = \"Hello, World!\";\n let my_vec = s.parse::<MyVec>().unwrap();\n println!(\"{}\", my_vec);\n}"}
18
+ {"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.", "gen": "// Define the newtype wrapper for [u8; 32]\n#[derive(Debug, PartialEq, Eq)]\nstruct Bytes32([u8; 32]);\n\nimpl std::str::FromStr for Bytes32 {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 64 {\n return Err(std::num::ParseIntError);\n }\n let mut bytes = [0u8; 32];\n for (i, c) in s.as_bytes().iter().enumerate() {\n bytes[i] = *c;\n }\n Ok(Bytes32(bytes))\n }\n}\n\nimpl std::fmt::Display for Bytes32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n let mut s = String::with_capacity(64);\n for c in &self.0 {\n s.push(*c as char);\n }\n write!(f, \"{}\", s)\n }\n}\n\nfn main() {\n let bytes = Bytes32::from_str(\"0123456789abcdef0123456789abcdef\").unwrap();\n println!(\"{:?}\", bytes);\n println!(\"{}\", bytes);\n}"}
19
+ {"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.", "gen": "#[derive(Debug, PartialEq, Eq, Clone, Hash, Default, PartialOrd, Ord)]\nstruct HexString([u8; 32]);\n\nimpl FromStr for HexString {\n type Err = std::num::ParseIntError;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n let mut arr = [0u8; 32];\n let bytes = hex::decode(s).map_err(|_| Self::Err::from(\"Invalid hex string\"))?;\n arr.copy_from_slice(&bytes);\n Ok(Self(arr))\n }\n}\n\nimpl Display for HexString {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n let s = hex::encode(&self.0);\n write!(f, \"{}\", s)\n }\n}\n\nfn main() {\n let s = \"deadbeef\";\n let hex_string = s.parse::<HexString>().unwrap();\n println!(\"{:?}\", hex_string);\n println!(\"{}\", hex_string);\n}"}
20
+ {"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.", "gen": "#[derive(Debug)]\nstruct ByteSlice32([u8; 32]);\n\nimpl std::str::FromStr for ByteSlice32 {\n type Err = std::num::ParseIntError;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(std::num::ParseIntError::new(\"invalid length\"));\n }\n\n let mut bytes = [0; 32];\n for (i, c) in s.bytes().enumerate() {\n if c < b'0' || c > b'9' {\n return Err(std::num::ParseIntError::new(\"invalid character\"));\n }\n bytes[i] = (c - b'0') as u8;\n }\n\n Ok(ByteSlice32(bytes))\n }\n}\n\nimpl std::fmt::Display for ByteSlice32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n for &b in &self.0 {\n write!(f, \"{:02x}\", b)?;\n }\n Ok(())\n }\n}\n\nfn main() {\n let bs = ByteSlice32::from_str(\"1234567890abcdef\").unwrap();\n println!(\"{:?}\", bs);\n println!(\"{}\", bs);\n}"}
21
+ {"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.", "gen": "#[derive(Debug)]\nstruct Hash32([u8; 32]);\n\nimpl FromStr for Hash32 {\n type Err = &'static str;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n Err(\"Invalid hash length\")\n } else {\n let mut bytes = [0u8; 32];\n for (i, byte) in bytes.iter_mut().enumerate() {\n *byte = s.as_bytes()[i].into();\n }\n Ok(Hash32(bytes))\n }\n }\n}\n\nimpl std::fmt::Display for Hash32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n for byte in &self.0 {\n write!(f, \"{:02x}\", byte)?;\n }\n Ok(())\n }\n}\n\nfn main() {\n let hash = Hash32::from_str(\"f7bb3e2f9d1f5d9a8e8d7c6b5a4\").unwrap();\n println!(\"{:?}\", hash);\n println!(\"{}\", hash);\n}"}
22
+ {"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.", "gen": "#[derive(thiserror::Error, Debug)]\nenum MyError {\n #[error(\"error 1\")]\n Error1,\n\n #[error(\"error 2\")]\n Error2 {\n source: Box<dyn std::error::Error + Send + Sync +'static>,\n },\n}\n\nimpl std::fmt::Display for MyError {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n match self {\n Self::Error1 => write!(f, \"error 1\"),\n Self::Error2 { source } => write!(f, \"error 2: {}\", source),\n }\n }\n}\n\nfn run() -> Result<(), MyError> {\n let x = 1;\n let y = 2;\n if x == y {\n Ok(())\n } else {\n Err(MyError::Error1)\n }?\n Err(MyError::Error2 {\n source: Box::new(std::io::Error::new(\n std::io::ErrorKind::NotFound,\n \"file not found\",\n )),\n })\n}\n\nfn main() {\n if let Err(e) = run() {\n eprintln!(\"{}\", e);\n }\n}"}
23
+ {"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.", "gen": "#[derive(thiserror::Error, Debug)]\npub enum Error {\n #[error(transparent)]\n Custom(Box<dyn std::error::Error + Send + Sync>),\n #[error(\"invalid length\")]\n InvalidLength,\n #[error(\"invalid length\")]\n InvalidLength2,\n}\n\nimpl Error {\n pub fn new() -> Self {\n Self::InvalidLength\n }\n}\n\nfn process(data: &[u8]) -> Result<(), Error> {\n if data.len() < 4 {\n return Err(Error::new());\n }\n Ok(())\n}\n\nfn main() -> Result<(), Error> {\n process(&[1, 2, 3])?;\n Ok(())\n}"}
24
+ {"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.", "gen": "use thiserror::Error;\nuse std::fmt;\n\n#[derive(Error, Debug)]\nenum MyError {\n #[error(\"invalid input\")]\n InvalidInput,\n #[error(\"out of bounds\")]\n OutOfBounds,\n}\n\nimpl fmt::Display for MyError {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n write!(f, \"{:?}\", self)\n }\n}\n\nfn process_input(input: &[u32]) -> Result<(), MyError> {\n let len = input.len();\n let idx = 2;\n\n if idx < len {\n Ok(())\n } else {\n Err(MyError::OutOfBounds)\n }\n}\n\nfn main() -> Result<(), MyError> {\n let input = &[1, 2, 3];\n process_input(input)?;\n Ok(())\n}"}
25
+ {"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.", "gen": "use std::error::Error;\nuse std::fmt;\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\n#[allow(dead_code)]\nenum MyError {\n #[error(\"No data\")]\n NoData,\n #[error(\"Too many data\")]\n TooManyData,\n}\n\nimpl fmt::Display for MyError {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"{:?}\", self)\n }\n}\n\nfn get_data() -> Result<i32, MyError> {\n if false {\n Err(MyError::NoData)\n } else {\n Err(MyError::TooManyData)\n }\n}\n\nfn main() -> Result<(), Box<dyn Error>> {\n let data = get_data()?;\n Ok(())\n}"}
26
+ {"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.", "gen": "use thiserror::Error;\n\n#[derive(thiserror::Error, Debug, Clone, PartialEq)]\n#[allow(missing_docs)]\npub enum MyError {\n #[error(\"Invalid length: {0}\")]\n InvalidLength(u8),\n #[error(\"Invalid value: {0}\")]\n InvalidValue(String),\n}\n\nfn do_something(value: u8) -> Result<(), MyError> {\n if value > 10 {\n Err(MyError::InvalidValue(String::from(\"value too big\")))\n } else if value < 5 {\n Err(MyError::InvalidValue(String::from(\"value too small\")))\n } else {\n Ok(())\n }\n}\n\nfn main() {\n if let Err(e) = do_something(12) {\n println!(\"Something went wrong: {:#?}\", e);\n } else {\n println!(\"All good\");\n }\n}"}
27
+ {"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.", "gen": "#[derive(thiserror::Error, Debug, Display)]\nenum MyError {\n DivisionByZero,\n NegativeInput,\n StringEmpty,\n}\n\nimpl From<std::num::TryFromIntError> for MyError {\n fn from(_: std::num::TryFromIntError) -> Self {\n MyError::DivisionByZero\n }\n}\n\nfn main() -> Result<(), MyError> {\n let result = try {\n let x = -1;\n let y = 0;\n if y == 0 {\n return Err(MyError::DivisionByZero);\n }\n Ok(x / y)\n } catch |e| {\n eprintln!(\"Error: {}\", e);\n Err(MyError::NegativeInput)\n };\n\n if result.is_err() {\n return Err(MyError::StringEmpty);\n }\n Ok(())\n}"}
28
+ {"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.", "gen": "use thiserror::Error;\n\n#[derive(Debug, Error)]\n#[error(transparent)]\npub enum MyError {\n #[error(transparent)]\n Other(#[from] std::io::Error),\n}\n\nimpl std::fmt::Display for MyError {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n match self {\n Self::Other(e) => write!(f, \"Error: {}\", e),\n }\n }\n}\n\nfn run() -> Result<(), MyError> {\n let file = \"hello.txt\";\n let contents = std::fs::read_to_string(file)?;\n\n Ok(())\n}\n\nfn main() {\n if let Err(e) = run() {\n eprintln!(\"Error: {}\", e);\n }\n}"}
29
+ {"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.", "gen": "use std::collections::HashMap;\n\nfn main() {\n let some_map = Some(HashMap::new());\n\n // Pattern matching with `match`\n match some_map {\n Some(map) => {\n println!(\"Matched Some: {:?}\", map);\n },\n None => {\n println!(\"Matched None\");\n },\n }\n\n // Pattern matching with `if let`\n if let Some(map) = some_map {\n println!(\"if let matched Some: {:?}\", map);\n } else {\n println!(\"if let matched None\");\n }\n}"}
30
+ {"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.", "gen": "// The `std` crate is the standard Rust library\nuse std::cmp::Ordering;\n\nfn main() {\n // Match with single pattern\n let number = 10;\n match number {\n 1 => println!(\"One\"),\n 2 => println!(\"Two\"),\n _ => println!(\"Other\"),\n }\n\n // Match with multiple patterns\n let number = 5;\n match number {\n 1 | 3 | 5 => println!(\"Odd\"),\n 2 | 4 | 6 => println!(\"Even\"),\n _ => println!(\"Other\"),\n }\n\n // Match with `if let`\n let number = 10;\n if let Some(n) = Some(5) {\n println!(\"Number is {}\", n);\n } else {\n println!(\"Number is not 5\");\n }\n\n // Match with `if let` with multiple arms\n let number = 10;\n if let Some(n) = Some(5) {\n println!(\"Number is {}\", n);\n } else if let Some(n) = Some(10) {\n println!(\"Number is {}\", n);\n } else {\n println!(\"Number is not 5 or 10\");\n }\n\n // Match with `if let` with multiple patterns\n let number = 5;\n if let 1 | 3 | 5 = number {\n println!(\"Odd\");\n } else {\n println!(\"Even\");\n }\n\n // Match with `if let` with `match` expression\n let number = 5;\n let result = match number {\n 1 | 3 | 5 => \"Odd\",\n 2 | 4 | 6 => \"Even\",\n _ => \"Other\",\n };\n println!(\"Result is {}\", result);\n\n // Match with `if let` with `match` expression and tuple\n let number = (5, 10);\n let result = match number {\n (1, 1) => \"One\",\n (2, 2) => \"Two\",\n (3, 3) => \"Three\",\n _ => \"Other\",\n };\n println!(\"Result is {}\", result);\n\n // Match with `if let` with `match` expression and tuple and ranges\n let number = (5, 10);\n let result = match number {\n (1..=3, 1..=3) => \"One\",\n (2..=4, 2..=4) => \"Two\",\n (3..=5, 3..=5) => \"Three\",\n _ => \"Other\",\n };\n println!(\"Result is {}\", result);\n}"}
31
+ {"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.", "gen": "// Import the necessary module\nuse std::collections::HashMap;\n\nfn main() {\n // Example 1: Pattern matching on a `HashMap` using `match`\n let mut map = HashMap::new();\n map.insert(\"name\", \"Bobby\");\n map.insert(\"age\", \"29\");\n match map.get(\"name\") {\n Some(value) => println!(\"Name is {}\", value),\n None => println!(\"Name not found\"),\n }\n match map.get(\"age\") {\n Some(value) => println!(\"Age is {}\", value),\n None => println!(\"Age not found\"),\n }\n\n // Example 2: Pattern matching on a `String` using `if let`\n let s = String::from(\"This is a sentence.\");\n if let Some(word) = s.split_whitespace().nth(0) {\n println!(\"First word: {}\", word);\n } else {\n println!(\"No words found.\");\n }\n\n // Example 3: Pattern matching on an `Option` using `if let`\n let opt: Option<i32> = Some(5);\n if let Some(value) = opt {\n println!(\"Value is {}\", value);\n } else {\n println!(\"No value.\");\n }\n}"}
32
+ {"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.", "gen": "fn main() {\n let some_option: Option<String> = Some(\"hello\".to_string());\n let none_option: Option<String> = None;\n let some_string = String::from(\"hello\");\n\n // match\n match some_option {\n Some(value) => {\n println!(\"Got value: {}\", value);\n }\n None => {\n println!(\"Got nothing\");\n }\n }\n\n // if let\n if let Some(value) = some_option {\n println!(\"Got value: {}\", value);\n } else {\n println!(\"Got nothing\");\n }\n\n // if let\n if let Some(value) = none_option {\n println!(\"Got value: {}\", value);\n } else {\n println!(\"Got nothing\");\n }\n\n // match\n match some_string {\n \"hello\" => {\n println!(\"Got hello\");\n }\n \"world\" => {\n println!(\"Got world\");\n }\n _ => {\n println!(\"Got something else\");\n }\n }\n\n // if let\n if let \"hello\" = &some_string {\n println!(\"Got hello\");\n } else {\n println!(\"Got something else\");\n }\n}"}
33
+ {"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.", "gen": "fn main() {\n let a = Some(1);\n let b = None;\n\n // Pattern matching with if let\n if let Some(i) = a {\n println!(\"a = {}\", i);\n } else {\n println!(\"a is None\");\n }\n\n // Pattern matching with match\n match b {\n Some(i) => println!(\"b = {}\", i),\n None => println!(\"b is None\"),\n }\n}"}
34
+ {"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.", "gen": "use std::io;\nuse std::io::prelude::*;\n\nfn main() {\n println!(\"Enter a number: \");\n let mut line = String::new();\n io::stdin().read_line(&mut line)\n .expect(\"Failed to read line\");\n let num: i32 = match line.trim().parse() {\n Ok(num) => num,\n Err(_) => {\n println!(\"Not a number!\");\n return;\n }\n };\n\n let result = if let Ok(num) = line.trim().parse() {\n if num == 1 {\n println!(\"One\");\n } else if num == 2 {\n println!(\"Two\");\n } else if num == 3 {\n println!(\"Three\");\n } else {\n println!(\"Not one, two or three!\");\n }\n num\n } else {\n println!(\"Not a number!\");\n return;\n };\n\n println!(\"You entered: {}\", result);\n}"}
35
+ {"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.", "gen": "use std::env;\nuse std::fs;\n\nfn main() {\n let args: Vec<String> = env::args().collect();\n\n if args.len() < 2 {\n println!(\"Usage: pattern_match <file>\");\n return;\n }\n\n let filename = &args[1];\n\n let contents = match fs::read_to_string(filename) {\n Ok(contents) => contents,\n Err(e) => {\n println!(\"Error: {}\", e);\n return;\n }\n };\n\n let line = match contents.lines().next() {\n Some(line) => line,\n None => {\n println!(\"No lines in file\");\n return;\n }\n };\n\n if let Ok(num) = line.parse::<i32>() {\n println!(\"The number is {}\", num);\n } else {\n println!(\"The line is not a number\");\n }\n}"}
36
+ {"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.", "gen": "#[derive(Debug)]\nstruct Person {\n name: String,\n age: u8,\n}\n\nimpl Person {\n fn new(name: String, age: u8) -> Person {\n Person { name, age }\n }\n\n fn greet(&self) {\n println!(\"Hi, I'm {} and I'm {} years old\", self.name, self.age);\n }\n}\n\ntrait Talk {\n fn speak(&self) -> String;\n}\n\nimpl Talk for Person {\n fn speak(&self) -> String {\n format!(\"Hello! My name is {}.\", self.name)\n }\n}\n\nfn main() {\n let p = Person::new(String::from(\"John\"), 30);\n println!(\"{:?}\", p);\n p.greet();\n println!(\"{}\", p.speak());\n}"}
37
+ {"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.", "gen": "struct Person {\n name: String,\n age: u8,\n address: String,\n}\n\nimpl Person {\n fn new(name: &str, age: u8, address: &str) -> Self {\n Self {\n name: name.to_string(),\n age,\n address: address.to_string(),\n }\n }\n}\n\ntrait Talkable {\n fn talk(&self) -> String;\n}\n\nimpl Talkable for Person {\n fn talk(&self) -> String {\n format!(\"Hello, my name is {} and I'm {} years old.\", self.name, self.age)\n }\n}\n\nfn main() {\n let p = Person::new(\"John\", 30, \"123 Main St\");\n println!(\"{}\", p.talk());\n}"}
38
+ {"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.", "gen": "trait Animal {\n fn speak(&self) -> String;\n}\n\nstruct Dog {\n name: String,\n age: u8,\n}\n\nimpl Dog {\n fn speak(&self) -> String {\n return format!(\"{} says Woof\", self.name);\n }\n}\n\nfn main() {\n let dog = Dog { name: \"Max\".to_string(), age: 3 };\n let dog_speak = dog.speak();\n println!(\"{}\", dog_speak);\n}"}
39
+ {"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.", "gen": "use std::fmt::Display;\n\nstruct Point {\n x: i32,\n y: i32,\n}\n\nimpl Point {\n fn new(x: i32, y: i32) -> Self {\n Point { x, y }\n }\n\n fn is_origin(&self) -> bool {\n self.x == 0 && self.y == 0\n }\n\n fn to_string(&self) -> String {\n format!(\"({}, {})\", self.x, self.y)\n }\n}\n\ntrait Coordinate {\n fn x(&self) -> i32;\n fn y(&self) -> i32;\n}\n\nimpl Coordinate for Point {\n fn x(&self) -> i32 {\n self.x\n }\n\n fn y(&self) -> i32 {\n self.y\n }\n}\n\nfn main() {\n let origin = Point::new(0, 0);\n assert!(origin.is_origin());\n println!(\"{}\", origin.to_string());\n}"}
40
+ {"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.", "gen": "use std::fmt::Display;\n\nstruct Vector2 {\n x: i32,\n y: i32,\n}\n\nimpl Vector2 {\n pub fn new(x: i32, y: i32) -> Vector2 {\n Vector2 { x, y }\n }\n\n pub fn get_x(&self) -> i32 {\n self.x\n }\n\n pub fn get_y(&self) -> i32 {\n self.y\n }\n}\n\nimpl Display for Vector2 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n write!(f, \"Vector2({}x, {}y)\", self.x, self.y)\n }\n}\n\nfn main() {\n let v = Vector2::new(10, 20);\n println!(\"{}\", v);\n println!(\"x: {}\", v.get_x());\n println!(\"y: {}\", v.get_y());\n}"}
41
+ {"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.", "gen": "struct Point {\n x: i32,\n y: i32,\n}\n\nimpl Point {\n fn new(x: i32, y: i32) -> Self {\n Self { x, y }\n }\n\n fn distance_from_origin(&self) -> f64 {\n (self.x.pow(2) + self.y.pow(2)).sqrt() as f64\n }\n}\n\ntrait Colorful {\n fn color(&self) -> &'static str;\n}\n\nimpl Colorful for Point {\n fn color(&self) -> &'static str {\n if self.distance_from_origin() < 5.0 {\n \"red\"\n } else {\n \"blue\"\n }\n }\n}\n\nfn main() {\n let p1 = Point::new(3, 4);\n let p2 = Point::new(-1, 2);\n let p3 = Point::new(5, 5);\n let p4 = Point::new(0, 0);\n\n println!(\"Color of p1 is {}\", p1.color());\n println!(\"Color of p2 is {}\", p2.color());\n println!(\"Color of p3 is {}\", p3.color());\n println!(\"Color of p4 is {}\", p4.color());\n}"}
42
+ {"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.", "gen": "// Define a struct\nstruct User {\n id: u32,\n name: String,\n}\n\n// Define an implementation block for the struct\nimpl User {\n // Method to print the user information\n fn print_info(&self) {\n println!(\"Id: {}, Name: {}\", self.id, self.name);\n }\n}\n\n// Define a trait\ntrait UserTrait {\n // Method to return the user id\n fn get_id(&self) -> u32;\n}\n\n// Implement the trait for the struct\nimpl UserTrait for User {\n // Implement the `get_id` method\n fn get_id(&self) -> u32 {\n self.id\n }\n}\n\n// Define a main function\nfn main() {\n // Create a user instance\n let user = User {\n id: 123,\n name: \"John\".to_string(),\n };\n\n // Call the method defined in the implementation block\n user.print_info();\n\n // Call the method defined in the trait\n println!(\"Id: {}\", user.get_id());\n}"}
43
+ {"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.", "gen": "#[macro_use]\nextern crate serde_derive;\n\nuse serde_json::{json, Value};\n\n#[derive(Debug, Serialize, Deserialize)]\nstruct User {\n name: String,\n age: u8,\n email: String,\n}\n\nfn main() {\n let user = User {\n name: \"John\".to_string(),\n age: 30,\n email: \"[email protected]\".to_string(),\n };\n\n let json_user = serde_json::to_string(&user).unwrap();\n println!(\"JSON: {}\", json_user);\n\n let user_deserialized: User = serde_json::from_str(&json_user).unwrap();\n println!(\"Deserialized User: {:?}\", user_deserialized);\n}"}
44
+ {"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.", "gen": "use serde::{Deserialize, Serialize};\n\n#[derive(Debug, Serialize, Deserialize)]\nstruct Person {\n name: String,\n age: u8,\n}\n\nfn main() {\n let person = Person {\n name: \"John\".to_string(),\n age: 30,\n };\n\n let serialized = serde_json::to_string(&person).unwrap();\n let deserialized: Person = serde_json::from_str(&serialized).unwrap();\n\n println!(\"serialized = {}\", serialized);\n println!(\"deserialized = {:?}\", deserialized);\n}"}
45
+ {"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.", "gen": "#[macro_use]\nextern crate serde_derive;\n\n#[macro_use]\nextern crate serde_json;\n\nuse serde_json::Result;\n\n#[derive(Serialize, Deserialize, Debug)]\nstruct Person {\n name: String,\n age: u8,\n occupation: String,\n salary: f64,\n}\n\nfn main() -> Result<()> {\n let person = Person {\n name: \"John\".to_string(),\n age: 30,\n occupation: \"Software Developer\".to_string(),\n salary: 60000.0,\n };\n\n let json = serde_json::to_string(&person)?;\n println!(\"JSON: {}\", json);\n\n let deserialized: Person = serde_json::from_str(&json)?;\n println!(\"Deserialized: {:?}\", deserialized);\n\n Ok(())\n}"}
46
+ {"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.", "gen": "use serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct MyStruct {\n a: i32,\n b: String,\n}\n\nfn main() {\n let s = MyStruct { a: 42, b: \"hello\".to_string() };\n\n let serialized = serde_json::to_string(&s).unwrap();\n println!(\"serialized = {}\", serialized);\n\n let deserialized: MyStruct = serde_json::from_str(&serialized).unwrap();\n println!(\"deserialized = {:?}\", deserialized);\n}"}
47
+ {"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.", "gen": "use serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct Person {\n name: String,\n age: u8,\n}\n\nfn main() {\n let person = Person {\n name: \"John\".to_string(),\n age: 30,\n };\n\n let serialized = serde_json::to_string(&person).unwrap();\n println!(\"serialized person = {}\", serialized);\n\n let deserialized: Person = serde_json::from_str(&serialized).unwrap();\n println!(\"deserialized person = {:?}\", deserialized);\n}"}
48
+ {"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.", "gen": "use serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct Person {\n name: String,\n age: u8,\n}\n\nfn main() {\n let person = Person {\n name: \"John\".to_string(),\n age: 30,\n };\n\n let serialized = serde_json::to_string(&person).unwrap();\n println!(\"serialized person = {}\", serialized);\n\n let deserialized: Person = serde_json::from_str(&serialized).unwrap();\n println!(\"deserialized person = {:#?}\", deserialized);\n}"}
49
+ {"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.", "gen": "use serde::{Deserialize, Serialize};\nuse serde_json;\n\n#[derive(Debug, Serialize, Deserialize)]\nstruct User {\n name: String,\n age: u32,\n}\n\nfn main() {\n let user = User {\n name: \"John\".to_string(),\n age: 30,\n };\n\n let json = serde_json::to_string(&user).unwrap();\n println!(\"JSON: {}\", json);\n\n let user: User = serde_json::from_str(&json).unwrap();\n println!(\"User: {:?}\", user);\n}"}
50
+ {"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.", "gen": "use regex::Regex;\n\nfn main() {\n let text = \"This is an example text. I like to eat eggs and ham and cheese. I am a cat.\";\n let mut re = Regex::new(r\"(\\w+) and (\\w+)\").unwrap();\n let replaced = re.replace_all(&text, \"and $2\");\n println!(\"{}\", replaced);\n}"}
51
+ {"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.", "gen": "use regex::Regex;\n\nfn main() {\n let text = \"Hello, world! My name is John, and I'm a developer.\";\n let mut regex = Regex::new(r\"world\").unwrap();\n let new_text = regex.replace_all(&text, \"Rustacean\");\n println!(\"Original: {}\", text);\n println!(\"Replaced: {}\", new_text);\n}"}
52
+ {"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.", "gen": "use regex::Regex;\n\nfn main() {\n let re = Regex::new(r\"(\\d+)\").unwrap();\n let text = \"I have 1 apple and 2 oranges and 3 bananas\";\n let replaced = re.replace_all(&text, \"number $1\");\n println!(\"{}\", replaced);\n}"}
53
+ {"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.", "gen": "use regex::Regex;\n\nfn main() {\n let text = \"Hello, world! Hello, world! Hello, world! Hello, world!\";\n\n let re = Regex::new(r\"Hello, world!\").unwrap();\n\n let new_text = re.replace_all(&text, \"Goodbye, world!\");\n\n println!(\"{}\", new_text);\n}"}
54
+ {"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.", "gen": "use regex::Regex;\n\nfn main() {\n let text = \"The quick brown fox jumps over the lazy dog\";\n let re = Regex::new(r\"fox|lazy\").unwrap();\n let new_text = re.replace_all(&text, \"bat\");\n println!(\"{}\", new_text);\n}"}
55
+ {"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.", "gen": "use regex::Regex;\n\nfn main() {\n let text = \"This is a simple example of a text that we want to modify.\";\n let re = Regex::new(r\"simple\").unwrap();\n let text = re.replace_all(&text, \"complex\").to_string();\n println!(\"{}\", text);\n}"}
56
+ {"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.", "gen": "use regex::Regex;"}
57
+ {"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.", "gen": "use chrono::prelude::*;\n\nfn main() {\n let date = Local::today();\n let formatted = format!(\"{}\", date.format(\"%a %b %d %Y %H:%M:%S\"));\n println!(\"{}\", formatted);\n\n let date = Local::now();\n let formatted = format!(\"{}\", date.format(\"%A %B %d, %Y %H:%M:%S\"));\n println!(\"{}\", formatted);\n\n let date = Local::now();\n let formatted = format!(\"{}\", date.format(\"%A %B %d, %Y %I:%M %p\"));\n println!(\"{}\", formatted);\n}"}
58
+ {"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.", "gen": "use chrono::prelude::*;\n\nfn main() {\n let date = \"2022-07-26T14:30:00\";\n let date = DateTime::parse_from_rfc3339(date).unwrap();\n let formatted_date = date.format(\"%B %e %Y\").to_string();\n println!(\"{}\", formatted_date);\n\n let date = \"2022-07-26T14:30:00\";\n let date = DateTime::parse_from_rfc3339(date).unwrap();\n let formatted_date = date.format(\"%B %e %Y %T\").to_string();\n println!(\"{}\", formatted_date);\n\n let date = \"2022-07-26T14:30:00\";\n let date = DateTime::parse_from_rfc3339(date).unwrap();\n let formatted_date = date.format(\"%B %e %Y %T %:z\").to_string();\n println!(\"{}\", formatted_date);\n}"}
59
+ {"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.", "gen": "use chrono::{DateTime, Local};\nuse chrono::format::{Item, ParseResult, ParseWeekday, ParseYear};\n\nfn parse_date(date: &str) -> Option<DateTime<Local>> {\n match date.parse::<Local>() {\n Ok(dt) => Some(dt),\n Err(_) => None,\n }\n}\n\nfn format_date(dt: &DateTime<Local>, format: &str) -> String {\n dt.format(format).to_string()\n}\n\nfn main() {\n // Example 1\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%a %b %d %Y %H:%M:%S\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 2\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y-%m-%d %H:%M:%S\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 3\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 4\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 5\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %P\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 6\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 7\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %P %Z\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 8\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %z\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 9\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %P %z\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 10\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 11\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %P %Z%z\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 12\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %p\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 13\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %P %Z%z %p\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 14\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %P\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 15\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %P\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 16\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %p\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 17\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %p\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 18\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %P\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 19\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %P\");\n println!(\"{} -> {}\", date, formatted);\n\n // Example 20\n let date = \"2022-08-12 11:12:13\";\n let date = parse_date(date).unwrap();\n let formatted = format_date(&date, \"%Y/%m/%d %H:%M:%S %p %Z%z %p\");\n println!(\"{} -> {}\", date, formatted);\n}"}
60
+ {"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.", "gen": "use chrono::{DateTime, DateTime, Local};\nuse chrono::format::PST;\n\nfn main() {\n let date = \"2021-04-01\";\n let parsed_date: DateTime<Local> = DateTime::parse_from_rfc3339(date).unwrap();\n let formatted_date = parsed_date.with_timezone(&PST).format(\"%A, %B %e, %Y %r\");\n println!(\"Date: {}\", formatted_date);\n\n let date = \"2021-03-01T12:00:00Z\";\n let parsed_date: DateTime<Local> = DateTime::parse_from_rfc3339(date).unwrap();\n let formatted_date = parsed_date.with_timezone(&PST).format(\"%A, %B %e, %Y %r\");\n println!(\"Date: {}\", formatted_date);\n}"}
61
+ {"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.", "gen": "use chrono::{DateTime, Local, NaiveDateTime, Utc};\n\nfn main() {\n let local_now = Local::now();\n let utc_now = Utc::now();\n let naive_now = NaiveDateTime::from_timestamp(0, 0);\n\n let local_now_str = local_now.to_rfc3339();\n let utc_now_str = utc_now.to_rfc3339();\n let naive_now_str = naive_now.to_rfc3339();\n\n println!(\"Local now: {}\", local_now_str);\n println!(\"UTC now: {}\", utc_now_str);\n println!(\"Naive now: {}\", naive_now_str);\n}"}
62
+ {"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.", "gen": "use chrono::{DateTime, Local};\nuse chrono::format::Item;\nuse chrono::format::ParseResult;"}
63
+ {"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.", "gen": "use chrono::prelude::*;\nuse chrono::format::PcDateTime;\n\nfn main() {\n let date = Local.ymd(2020, 1, 1).and_hms(10, 11, 12);\n let date = Local.ymd(2020, 1, 1).and_hms_milli(10, 11, 12, 13);\n let date = Local.ymd(2020, 1, 1).and_hms_micro(10, 11, 12, 13, 14);\n let date = Local.ymd(2020, 1, 1).and_hms_nano(10, 11, 12, 13, 14, 15);\n\n println!(\"Local time: {}\", date.format(\"%Y-%m-%d %H:%M:%S\"));\n println!(\"Local time: {}\", date.format(\"%Y-%m-%d %H:%M:%S%.f\"));\n println!(\"Local time: {}\", date.format(\"%Y-%m-%d %H:%M:%S%.9f\"));\n println!(\"Local time: {}\", date.format(\"%Y-%m-%d %H:%M:%S%.9f\"));\n}"}
64
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n let random_uuid = Uuid::new_v4();\n let random_uuid1 = Uuid::new_v4();\n let random_uuid2 = Uuid::new_v4();\n let random_uuid3 = Uuid::new_v4();\n let random_uuid4 = Uuid::new_v4();\n let random_uuid5 = Uuid::new_v4();\n\n println!(\"{:?}\", random_uuid);\n println!(\"{:?}\", random_uuid1);\n println!(\"{:?}\", random_uuid2);\n println!(\"{:?}\", random_uuid3);\n println!(\"{:?}\", random_uuid4);\n println!(\"{:?}\", random_uuid5);\n}"}
65
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n println!(\"{}\", Uuid::new_v4());\n println!(\"{}\", Uuid::new_v4());\n println!(\"{}\", Uuid::new_v4());\n}"}
66
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n println!(\"v4: {:#}\", Uuid::new_v4());\n println!(\"v5: {:#}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\"));\n println!(\"v5: {:#}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\").to_hyphenated().to_string());\n println!(\"v5: {:#}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\").to_hyphenated());\n println!(\"v5: {:#}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\").to_string());\n}"}
67
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n let a = Uuid::new_v4();\n let b = Uuid::new_v4();\n let c = Uuid::new_v4();\n let d = Uuid::new_v4();\n let e = Uuid::new_v4();\n let f = Uuid::new_v4();\n let g = Uuid::new_v4();\n let h = Uuid::new_v4();\n let i = Uuid::new_v4();\n let j = Uuid::new_v4();\n let k = Uuid::new_v4();\n let l = Uuid::new_v4();\n let m = Uuid::new_v4();\n let n = Uuid::new_v4();\n let o = Uuid::new_v4();\n let p = Uuid::new_v4();\n let q = Uuid::new_v4();\n let r = Uuid::new_v4();\n let s = Uuid::new_v4();\n let t = Uuid::new_v4();\n let u = Uuid::new_v4();\n let v = Uuid::new_v4();\n let w = Uuid::new_v4();\n let x = Uuid::new_v4();\n let y = Uuid::new_v4();\n let z = Uuid::new_v4();\n\n println!(\"a: {}\", a);\n println!(\"b: {}\", b);\n println!(\"c: {}\", c);\n println!(\"d: {}\", d);\n println!(\"e: {}\", e);\n println!(\"f: {}\", f);\n println!(\"g: {}\", g);\n println!(\"h: {}\", h);\n println!(\"i: {}\", i);\n println!(\"j: {}\", j);\n println!(\"k: {}\", k);\n println!(\"l: {}\", l);\n println!(\"m: {}\", m);\n println!(\"n: {}\", n);\n println!(\"o: {}\", o);\n println!(\"p: {}\", p);\n println!(\"q: {}\", q);\n println!(\"r: {}\", r);\n println!(\"s: {}\", s);\n println!(\"t: {}\", t);\n println!(\"u: {}\", u);\n println!(\"v: {}\", v);\n println!(\"w: {}\", w);\n println!(\"x: {}\", x);\n println!(\"y: {}\", y);\n println!(\"z: {}\", z);\n}"}
68
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n // Generate a random UUID\n let random_uuid = Uuid::new_v4();\n println!(\"{}\", random_uuid);\n \n // Generate a random UUID with a specific version\n let random_uuid_v5 = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\");\n println!(\"{}\", random_uuid_v5);\n \n // Generate a random UUID with a specific version and namespace\n let random_uuid_v6 = Uuid::new_v6(Uuid::NAMESPACE_DNS);\n println!(\"{}\", random_uuid_v6);\n \n // Generate a random UUID with a specific version and namespace\n let random_uuid_v7 = Uuid::new_v7(Uuid::NAMESPACE_DNS);\n println!(\"{}\", random_uuid_v7);\n}"}
69
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n let id1 = Uuid::new_v4();\n let id2 = Uuid::parse_str(\"2d7b0a88-8c0a-4d8a-9b89-9e8d4e7e9f1b\").unwrap();\n let id3 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id4 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id5 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id6 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id7 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id8 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id9 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n let id10 = Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap();\n\n println!(\"Uuid v4: {}\", id1);\n println!(\"Uuid v4: {}\", id2);\n println!(\"Uuid v4: {}\", id3);\n println!(\"Uuid v4: {}\", id4);\n println!(\"Uuid v4: {}\", id5);\n println!(\"Uuid v4: {}\", id6);\n println!(\"Uuid v4: {}\", id7);\n println!(\"Uuid v4: {}\", id8);\n println!(\"Uuid v4: {}\", id9);\n println!(\"Uuid v4: {}\", id10);\n}"}
70
+ {"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.", "gen": "use uuid::Uuid;\n\nfn main() {\n let random_uuid = Uuid::new_v4();\n println!(\"Random UUID: {}\", random_uuid);\n\n let random_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"https://www.rust-lang.org/\");\n println!(\"Random UUID: {}\", random_uuid);\n\n let random_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"https://www.rust-lang.org\");\n println!(\"Random UUID: {}\", random_uuid);\n\n let random_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"https://www.rust-lang.org/\");\n println!(\"Random UUID: {}\", random_uuid);\n\n let random_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"https://www.rust-lang.org\");\n println!(\"Random UUID: {}\", random_uuid);\n}"}
71
+ {"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.", "gen": "use rand::prelude::*;\n\nfn main() {\n let random_number = thread_rng().gen_range(1, 10);\n let mut random_numbers: Vec<u8> = Vec::new();\n\n for i in 0..random_number {\n random_numbers.push(i);\n }\n\n println!(\"Random number: {}\", random_number);\n println!(\"Random numbers: {:?}\", random_numbers);\n}"}
72
+ {"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.", "gen": "use rand::prelude::*;\n\nfn main() {\n let numbers = vec![1, 2, 3, 4, 5];\n let mut rng = thread_rng();\n let mut index: usize = rng.gen_range(0, numbers.len());\n loop {\n println!(\"Random number: {}\", numbers[index]);\n index = rng.gen_range(0, numbers.len());\n }\n}"}
73
+ {"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.", "gen": "use rand::prelude::*;\n\nfn main() {\n let mut rng = thread_rng();\n\n let mut vector = Vec::new();\n let size = 10;\n\n for i in 0..size {\n vector.push(i);\n }\n\n let mut random_numbers = Vec::new();\n let mut selected_numbers = Vec::new();\n\n for _ in 0..size {\n let random_number = rng.gen_range(0..size);\n random_numbers.push(random_number);\n }\n\n for i in 0..size {\n let random_number = random_numbers[i];\n let mut index = -1;\n for j in 0..size {\n if vector[j] == random_number {\n index = j;\n break;\n }\n }\n if index!= -1 {\n selected_numbers.push(vector[index]);\n vector.remove(index);\n }\n }\n\n println!(\"Selected numbers:\");\n for i in 0..size {\n println!(\"{}: {}\", i, selected_numbers[i]);\n }\n}"}
74
+ {"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.", "gen": "use rand::prelude::*;\nuse rand::Rng;\n\nfn main() {\n let mut rng = thread_rng();\n let mut random_number: u8 = rng.gen_range(1, 101);\n let mut random_number2: u8 = rng.gen_range(1, 101);\n let mut random_number3: u8 = rng.gen_range(1, 101);\n let mut random_number4: u8 = rng.gen_range(1, 101);\n\n let mut vec: Vec<u8> = Vec::new();\n vec.push(random_number);\n vec.push(random_number2);\n vec.push(random_number3);\n vec.push(random_number4);\n\n let random_item = rng.gen_range(0, vec.len());\n println!(\"Random number 1: {}\", random_number);\n println!(\"Random number 2: {}\", random_number2);\n println!(\"Random number 3: {}\", random_number3);\n println!(\"Random number 4: {}\", random_number4);\n println!(\"Random item: {}\", vec[random_item]);\n}"}
75
+ {"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.", "gen": "use rand::prelude::*;\nuse rand::Rng;\nuse rand::distributions::Alphanumeric;\n\nfn main() {\n let mut rng = thread_rng();\n\n let items = vec![\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\", \"fig\"];\n let choice = &items[rng.gen_range(0..items.len())];\n\n let letters = Alphanumeric::new().unwrap();\n let password = letters.sample_iter(&mut rng).take(10).collect::<String>();\n println!(\"Random item: {} - Random password: {}\", choice, password);\n}"}
76
+ {"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.", "gen": "use rand::prelude::*;\nuse rand::rngs::SmallRng;\nuse rand::distributions::WeightedIndex;\nuse std::collections::HashMap;\n\nfn main() {\n let mut rng = SmallRng::seed_from_u64(0);\n\n // Create a weighted distribution of items\n let mut weights: HashMap<&str, u64> = HashMap::new();\n weights.insert(\"apple\", 1);\n weights.insert(\"banana\", 2);\n weights.insert(\"orange\", 3);\n let weights: Vec<u64> = weights.iter().map(|(_k, v)| *v).collect();\n let items: Vec<&str> = weights.iter().map(|v| {\n weights.iter()\n .enumerate()\n .find(|(_, w)| **w == *v)\n .unwrap()\n .0\n }).collect();\n\n // Create a weighted index\n let weighted_index = WeightedIndex::new(&weights).unwrap();\n\n // Generate a random number from the weighted distribution\n let random_index: usize = weighted_index.sample(&mut rng);\n\n // Print the random number\n println!(\"{}\", items[random_index]);\n}"}
77
+ {"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.", "gen": "use rand::Rng;\nuse rand::distributions::{Distribution, Uniform};\n\nfn main() {\n let mut rng = rand::thread_rng();\n\n let items: Vec<String> = vec![\n \"Apple\".to_string(),\n \"Banana\".to_string(),\n \"Cherry\".to_string(),\n \"Date\".to_string(),\n \"Elderberry\".to_string(),\n \"Fig\".to_string(),\n \"Grape\".to_string(),\n \"Honeydew\".to_string(),\n \"Ice cream\".to_string(),\n \"Jackfruit\".to_string(),\n \"Kiwi\".to_string(),\n \"Lemon\".to_string(),\n \"Mango\".to_string(),\n \"Nectarine\".to_string(),\n \"Orange\".to_string(),\n \"Pineapple\".to_string(),\n \"Quince\".to_string(),\n \"Raspberry\".to_string(),\n \"Strawberry\".to_string(),\n \"Tangerine\".to_string(),\n \"Ugli fruit\".to_string(),\n \"Vineapple\".to_string(),\n \"Watermelon\".to_string(),\n \"Xigua\".to_string(),\n \"Yuzu\".to_string(),\n \"Zucchini\".to_string(),\n ];\n\n let number = Uniform::from(0..items.len());\n let mut random_number: usize = rng.sample(number);\n\n loop {\n let random_item = &items[random_number];\n println!(\"{}\", random_item);\n\n random_number = rng.sample(number);\n }\n}"}