Superuser666-Sigil commited on
Commit
0713d5b
·
verified ·
1 Parent(s): 5a4e691

Upload checkpoint-5000 evaluation errors

Browse files
Files changed (1) hide show
  1. checkpoint-5000/errors.jsonl +27 -31
checkpoint-5000/errors.jsonl CHANGED
@@ -1,31 +1,27 @@
1
- {"sample_index": 1, "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.", "code": "use std::collections::HashMap;\nuse std::env;\n\nfn main() {\n let mut map = HashMap::new();\n map.insert(\"one\", 1);\n map.insert(\"two\", 2);\n map.insert(\"three\", 3);\n map.insert(\"four\", 4);\n map.insert(\"five\", 5);\n\n // Match with pattern\n match map.get(\"one\") {\n Some(&1) => println!(\"One is 1\"),\n Some(&2) => println!(\"One is 2\"),\n Some(&3) => println!(\"One is 3\"),\n Some(&4) => println!(\"One is 4\"),\n Some(&5) => println!(\"One is 5\"),\n So", "error_type": "other", "compile_error": "error: this file contains an unclosed delimiter\n --> src/main.rs:63:45\n |\n 4 | fn main() {\n | - unclosed delimiter\n...\n62 | } else {\n | - unclosed delimiter\n63 | println!(\"Eight is not in the map\");\n | ^\n\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
2
- {"sample_index": 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 blo", "code": "use anyhow::anyhow;\nuse anyhow::Result;\nuse std::io;\n\nfn main() -> Result<()> {\n let x = 10;\n let y = 0;\n let z = x / y;\n\n match z {\n Ok(_) => Ok(()),\n Err(e) => Err(anyhow!(e)),\n }\n}", "error_type": "type_mismatch", "compile_error": "warning: unused import: `std::io`\n --> src/main.rs:3:5\n |\n3 | use std::io;\n | ^^^^^^^\n |\n = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\nerror[E0308]: mismatched types\n --> src/main.rs:11:9\n |\n10 | match z {\n | - this expression has type `{integer}`\n11 | Ok(_) => Ok(()),\n | ^^^^^ expected integer, found `Result<_, _>`\n |\n = note: expected type `{integer}`\n found enum `Result<_, _>`\n\nerror[E0308]: mismatch"}
3
- {"sample_index": 3, "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.", "code": "#[derive(Debug)]\nstruct Bytes32([u8; 32]);\n\nimpl FromStr for Bytes32 {\n type Err = String;\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(\"Invalid length\".to_string());\n }\n let mut bytes = [0u8; 32];\n let mut i = 0;\n for byte in s.as_bytes() {\n bytes[i] = *byte;\n i += 1;\n }\n Ok(Bytes32(bytes))\n }\n}\n\nimpl Display for Bytes32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:4:6\n |\n4 | impl FromStr for Bytes32 {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n1 + use std::str::FromStr;\n |\n\nerror[E0405]: cannot find trait `Display` in this scope\n --> src/main.rs:20:6\n |\n20 | impl Display for Bytes32 {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n 1 + use std::fmt::Display;\n |\n\nerror[E0433]: failed to resolve: "}
4
- {"sample_index": 5, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n // match\n let x = 2;\n let y = match x {\n 1 => \"one\",\n 2 => \"two\",\n _ => \"unknown\",\n };\n\n println!(\"match: {}\", y);\n\n // if let\n let mut map = HashMap::new();\n map.insert(\"one\", 1);\n map.insert(\"two\", 2);\n if let Some(&v) = map.get(\"two\") {\n println!(\"if let: {}\", v);\n }\n\n // match with if let\n let x = 2;\n let y = match x {\n 1 => \"one\",\n 2 => {\n if let Some(&", "error_type": "type_mismatch", "compile_error": "error[E0308]: `match` arms have incompatible types\n --> src/main.rs:27:13\n |\n24 | let y = match x {\n | ------- `match` arms have incompatible types\n25 | 1 => \"one\",\n | ----- this is found to be of type `&str`\n26 | 2 => {\n27 | / if let Some(&v) = map.get(\"two\") {\n28 | | format!(\"two: {}\", v)\n29 | | } else {\n30 | | \"unknown\".to_string()\n31 | | }\n | |_____________^ exp"}
5
- {"sample_index": 7, "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.", "code": "pub struct Hash32([u8; 32]);\n\nimpl std::str::FromStr for Hash32 {\n type Err = String;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(\"Invalid hash length\".into());\n }\n\n let mut arr = [0; 32];\n for (i, b) in arr.iter_mut().enumerate() {\n *b = s.as_bytes()[i].into();\n }\n\n Ok(Hash32(arr))\n }\n}\n\nimpl std::fmt::Display for Hash32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt", "error_type": "trait_error", "compile_error": "error[E0599]: no function or associated item named `from_str` found for struct `Hash32` in the current scope\n --> src/main.rs:31:24\n |\n 1 | pub struct Hash32([u8; 32]);\n | ----------------- function or associated item `from_str` not found for this struct\n...\n31 | let hash = Hash32::from_str(\"d6d6a1b8d8b9a3f7b4f9c8c0f6b6c4f7a2d7c2a9c4d7a4f6c6a7d6f7b6f\").unwrap();\n | ^^^^^^^^ function or associated item not found in `Hash32`\n |\n = help: items from traits can o"}
6
- {"sample_index": 9, "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.", "code": "use thiserror::Error;\n\n#[derive(thiserror::Error, Debug, Display)]\nenum MyError {\n #[error(\"The value {0} is not in the range of 0..=100\")]\n InvalidValue(i32),\n #[error(\"No items in the list\")]\n EmptyList,\n #[error(\"An internal error\")]\n InternalError,\n}\n\nfn get_item_at_index<T>(list: &[T], index: usize) -> Result<&T, MyError> {\n if list.is_empty() {\n Err(MyError::EmptyList)\n } else if index < list.len() {\n Ok(&list[index])\n } else {\n Err(MyError::", "error_type": "undefined_variable", "compile_error": "error: cannot find derive macro `Display` in this scope\n --> src/main.rs:3:35\n |\n3 | #[derive(thiserror::Error, Debug, Display)]\n | ^^^^^^^\n\nwarning: unused import: `thiserror::Error`\n --> src/main.rs:1:5\n |\n1 | use thiserror::Error;\n | ^^^^^^^^^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\nerror[E0308]: mismatched types\n --> src/main.rs:19:35\n |\n19 | Err(MyError::InvalidValue(index))\n | "}
7
- {"sample_index": 10, "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.", "code": "use std::fmt;\n\n#[derive(Debug)]\nstruct U32Array(pub [u8; 32]);\n\nimpl FromStr for U32Array {\n type Err = String;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(\"Must be 32 characters long\".to_string());\n }\n let mut v = [0u8; 32];\n for (i, b) in s.bytes().enumerate() {\n v[i] = b;\n }\n Ok(U32Array(v))\n }\n}\n\nimpl fmt::Display for U32Array {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt:", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:6:6\n |\n6 | impl FromStr for U32Array {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n1 + use std::str::FromStr;\n |\n\nFor more information about this error, try `rustc --explain E0405`.\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
8
- {"sample_index": 11, "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.", "code": "use std::collections::HashMap;\nuse std::collections::hash_map::Entry;\n\nfn main() {\n // match statement\n let fruit = \"apple\";\n match fruit {\n \"apple\" => println!(\"You have an apple!\"),\n \"banana\" => println!(\"You have a banana!\"),\n \"orange\" => println!(\"You have an orange!\"),\n _ => println!(\"You have a fruit\"),\n }\n\n // if let statement\n let fruits = vec![\"apple\", \"banana\", \"orange\"];\n if let Some(fruit) = fruits.iter().next() {\n println!(\"The", "error_type": "other", "compile_error": "error: this file contains an unclosed delimiter\n --> src/main.rs:69:28\n |\n 4 | fn main() {\n | - unclosed delimiter\n...\n68 | if let (0, 0) = point {\n | - unclosed delimiter\n69 | println!(\"origin\");\n | ^\n\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
9
- {"sample_index": 13, "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.", "code": "#[derive(Debug)]\nstruct Hex32([u8; 32]);\n\nimpl FromStr for Hex32 {\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 hex = [0u8; 32];\n for i in 0..32 {\n hex[i] = u8::from_str_radix(&s[2 * i..2 * i + 2], 16)?;\n }\n Ok(Self(hex))\n }\n}\n\nimpl std::fmt::Display for Hex32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:4:6\n |\n4 | impl FromStr for Hex32 {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n1 + use std::str::FromStr;\n |\n\nerror[E0423]: expected value, found struct `std::num::ParseIntError`\n --> src/main.rs:8:24\n |\n8 | return Err(std::num::ParseIntError);\n | ^^^^^^^^^^^^^^^^^^^^^^^\n |\n --> /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/"}
10
- {"sample_index": 15, "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.", "code": "use thiserror::Error;\n\n#[derive(Debug, Error, PartialEq)]\npub enum MyError {\n #[error(\"Not enough items\")]\n NotEnoughItems,\n #[error(\"Too many items\")]\n TooManyItems,\n #[error(\"Unexpected EOF\")]\n UnexpectedEOF,\n}\n\nimpl std::fmt::Display for MyError {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n write!(f, \"{:?}\", self)\n }\n}\n\nfn get_items() -> Result<Vec<i32>, MyError> {\n let mut items = Vec::new();\n\n for _ in 0..5 {\n let item: ", "error_type": "type_mismatch", "compile_error": "error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`\n --> src/main.rs:25:33\n |\n25 | Ok(items.push(1); items.len() as i32)\n | ^\n | |\n | expected one of `)`, `,`, `.`, `?`, or an operator\n | help: missing `,`\n\nerror[E0119]: conflicting implementations of trait `std::fmt::Display` for type `MyError`\n --> src/main.rs:3:17\n |\n 3 "}
11
- {"sample_index": 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.", "code": "use std::fmt;\nuse std::str::FromStr;\n\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]\nstruct ThirtyTwoBytes([u8; 32]);\n\nimpl FromStr for ThirtyTwoBytes {\n type Err = std::num::ParseIntError;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n let mut buf = [0u8; 32];\n let len = s.len();\n if len > 32 {\n Err(std::num::ParseIntError)\n } else {\n for (i, ch) in s.bytes().enumerate() {\n buf[i] = ch;\n }\n Ok", "error_type": "type_mismatch", "compile_error": "error[E0423]: expected value, found struct `std::num::ParseIntError`\n --> src/main.rs:14:17\n |\n14 | Err(std::num::ParseIntError)\n | ^^^^^^^^^^^^^^^^^^^^^^^\n |\n --> /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/num/error.rs:65:1\n |\n = note: `std::num::ParseIntError` defined here\n\nFor more information about this error, try `rustc --explain E0423`.\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
12
- {"sample_index": 22, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n // Simple match\n let x = 1;\n match x {\n 1 => println!(\"one\"),\n 2 => println!(\"two\"),\n _ => println!(\"anything\"),\n }\n\n // if let\n let mut m = HashMap::new();\n m.insert(\"a\", 1);\n if let Some(x) = m.get_mut(&\"a\") {\n *x += 1;\n }\n\n // if let\n let mut m = HashMap::new();\n m.insert(\"a\", 1);\n if let Some(x) = m.get_mut(&\"a\") {\n *x += 1;\n }\n\n // let pattern\n let a = Some(5);\n ", "error_type": "other", "compile_error": "error: this file contains an unclosed delimiter\n --> src/main.rs:81:19\n |\n 3 | fn main() {\n | - unclosed delimiter\n...\n81 | // let pattern\n | ^\n\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
13
- {"sample_index": 23, "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.", "code": "use std::ops::Deref;\n\nstruct Foo {\n x: i32,\n y: i32,\n}\n\nimpl Foo {\n fn new(x: i32, y: i32) -> Self {\n Self { x, y }\n }\n}\n\nimpl Deref for Foo {\n type Target = (i32, i32);\n\n fn deref(&self) -> &Self::Target {\n (&self.x, &self.y)\n }\n}\n\nfn main() {\n let f = Foo::new(1, 2);\n let (x, y) = f;\n println!(\"x = {}, y = {}\", x, y);\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:18:9\n |\n17 | fn deref(&self) -> &Self::Target {\n | ------------- expected `&(i32, i32)` because of return type\n18 | (&self.x, &self.y)\n | ^^^^^^^^^^^^^^^^^^ expected `&(i32, i32)`, found `(&i32, &i32)`\n |\n = note: expected reference `&(_, _)`\n found tuple `(&_, &_)`\n\nerror[E0308]: mismatched types\n --> src/main.rs:24:9\n |\n24 | let (x, y) = f;\n | ^^^^^^ - this "}
14
- {"sample_index": 26, "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.", "code": "struct Vector {\n x: f64,\n y: f64,\n}\n\nimpl Vector {\n fn new(x: f64, y: f64) -> Vector {\n Vector { x, y }\n }\n fn magnitude(&self) -> f64 {\n (self.x.powi(2) + self.y.powi(2)).sqrt()\n }\n fn normalize(&self) -> Vector {\n let m = self.magnitude();\n Vector {\n x: self.x / m,\n y: self.y / m,\n }\n }\n}\n\ntrait Add {\n fn add(&self, other: Self) -> Self;\n}\n\nimpl Add for Vector {\n fn add(&self, other: Vector) -> Vector {\n ", "error_type": "other", "compile_error": "error[E0369]: cannot add `Vector` to `Vector`\n --> src/main.rs:38:17\n |\n38 | let v3 = v1 + v2;\n | -- ^ -- Vector\n | |\n | Vector\n |\nnote: an implementation of `std::ops::Add` might be missing for `Vector`\n --> src/main.rs:1:1\n |\n 1 | struct Vector {\n | ^^^^^^^^^^^^^ must implement `std::ops::Add`\nnote: the trait `std::ops::Add` must be implemented\n --> /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/arith.rs:77:1\n\nFo"}
15
- {"sample_index": 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.", "code": "use std::io;\n\n#[derive(thiserror::Error, Debug)]\nenum MyError {\n Io(io::Error),\n Custom(String),\n}\n\nimpl From<io::Error> for MyError {\n fn from(e: io::Error) -> Self {\n MyError::Io(e)\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 MyError::Io(e) => e.fmt(f),\n MyError::Custom(s) => write!(f, \"Custom error: {}\", s),\n }\n }\n}\n\nfn main() {\n let result = do_s", "error_type": "type_mismatch", "compile_error": "error[E0277]: `?` couldn't convert the error to `MyError`\n --> src/main.rs:33:33\n |\n32 | fn do_something() -> Result<i32, MyError> {\n | -------------------- expected `MyError` because of this\n33 | let x: i32 = \"hello\".parse()?;\n | -------^ the trait `From<ParseIntError>` is not implemented for `MyError`\n | |\n | this can't be annotated with `?` because it has type `Result<_, ParseIntErro"}
16
- {"sample_index": 28, "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 blo", "code": "use anyhow::Result;\n\nfn main() -> Result<()> {\n let a: Result<String, std::num::ParseIntError> = \"a\".parse::<i32>();\n let b: Result<String, std::io::Error> = std::fs::read_to_string(\"nonexistent\");\n let c: Result<(), std::env::VarError> = std::env::var(\"nonexistent\");\n let d: Result<(), anyhow::Error> = Err(anyhow::anyhow!(\"oh no\"));\n\n a?;\n b?;\n c?;\n d?;\n\n Ok(())\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:4:54\n |\n4 | let a: Result<String, std::num::ParseIntError> = \"a\".parse::<i32>();\n | --------------------------------------- ^^^^^^^^^^^^^^^^^^ expected `Result<String, ParseIntError>`, found `Result<i32, ParseIntError>`\n | |\n | expected due to this\n |\n = note: expected enum `Result<String, _>`\n found enum `Result<i32, _>`\n\nerror[E0308]: mismatched types\n --> src/main.rs:6:45\n |\n6 | let c"}
17
- {"sample_index": 29, "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.", "code": "#[derive(thiserror::Error, Debug, PartialEq)]\nenum MyError {\n /// A generic error\n Generic,\n /// An error caused by invalid input\n InvalidInput(String),\n /// An error caused by invalid input that can be caused by other errors\n InvalidInputWithCause(InvalidInputWithCause),\n}\n\n#[derive(thiserror::Error, Debug, PartialEq)]\n#[error(\"Invalid input: {0}\")]\nstruct InvalidInput(String);\n\n#[derive(thiserror::Error, Debug, PartialEq)]\n#[error(transparent)]\nstruct InvalidInputWithCause(#[", "error_type": "type_mismatch", "compile_error": "error[E0277]: `MyError` doesn't implement `std::fmt::Display`\n --> src/main.rs:2:6\n |\n2 | enum MyError {\n | ^^^^^^^ unsatisfied trait bound\n |\nhelp: the trait `std::fmt::Display` is not implemented for `MyError`\n --> src/main.rs:2:1\n |\n2 | enum MyError {\n | ^^^^^^^^^^^^\nnote: required by a bound in `std::error::Error`\n --> /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/error.rs:53:1\n\nerror[E0308]: mismatched types\n --> src/main.rs:25:40\n |\n25 | Err(MyError::Inv"}
18
- {"sample_index": 31, "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.", "code": "#[derive(Debug, Clone, Copy, PartialEq)]\nstruct Key([u8; 32]);\n\nimpl Key {\n fn as_bytes(&self) -> [u8; 32] {\n *self\n }\n}\n\nimpl FromStr for Key {\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 let mut key = [0u8; 32];\n for (i, c) in s.as_bytes().iter().enumerate() {\n key[i] = *c;\n }\n Ok(Self", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:10:6\n |\n10 | impl FromStr for Key {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n 1 + use std::str::FromStr;\n |\n\nFor more information about this error, try `rustc --explain E0405`.\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
19
- {"sample_index": 32, "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.", "code": "#[derive(Debug, Clone, PartialEq, Eq)]\nstruct U32Bytes([u8; 32]);\n\nimpl FromStr for U32Bytes {\n type Err = String;\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(\"invalid length\".to_string());\n }\n let mut bytes = [0; 32];\n for (i, c) in s.bytes().enumerate() {\n bytes[i] = c as u8;\n }\n Ok(Self(bytes))\n }\n}\n\nimpl std::fmt::Display for U32Bytes {\n fn fmt(&self, f: &mut std::fmt::Formatter<", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:4:6\n |\n4 | impl FromStr for U32Bytes {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n1 + use std::str::FromStr;\n |\n\nFor more information about this error, try `rustc --explain E0405`.\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
20
- {"sample_index": 36, "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.", "code": "use std::iter::Iterator;\n\nfn main() {\n let arr = [2, 4, 6, 8, 10];\n let even = arr.iter().filter(|x| x % 2 == 0);\n let sum = even.sum::<i32>();\n println!(\"{}\", sum);\n}", "error_type": "other", "compile_error": "error[E0369]: cannot calculate the remainder of `&&{integer}` divided by `{integer}`\n --> src/main.rs:5:40\n |\n5 | let even = arr.iter().filter(|x| x % 2 == 0);\n | - ^ - {integer}\n | |\n | &&{integer}\n |\nhelp: `%` can be used on `&{integer}` if you dereference the left-hand side\n |\n5 | let even = arr.iter().filter(|x| *x % 2 == 0);\n | +\n"}
21
- {"sample_index": 38, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n let mut map: HashMap<String, i32> = HashMap::new();\n map.insert(\"a\".to_string(), 1);\n map.insert(\"b\".to_string(), 2);\n map.insert(\"c\".to_string(), 3);\n\n let sum = map\n .iter()\n .filter(|&(_, &x)| x % 2 == 0)\n .map(|&(_, &x)| x)\n .sum::<i32>();\n\n println!(\"Sum of even numbers is {}\", sum);\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:12:14\n |\n12 | .map(|&(_, &x)| x)\n | ^^^^^^^^\n | |\n | expected `(&String, &i32)`, found `&_`\n | expected due to this\n |\n = note: expected tuple `(&String, &i32)`\n found reference `&_`\n\nFor more information about this error, try `rustc --explain E0308`.\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
22
- {"sample_index": 41, "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.", "code": "#[derive(Debug, PartialEq)]\nstruct Bytes32([u8; 32]);\n\nimpl FromStr for Bytes32 {\n type Err = String;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 64 {\n return Err(\"length must be 64\".into());\n }\n let mut b = [0; 32];\n for (i, c) in s.as_bytes().iter().enumerate() {\n b[i / 2] |= (*c - 48) as u8 << ((8 * (i % 2)) as u8);\n }\n Ok(Bytes32(b))\n }\n}\n\nimpl std::fmt::Display for Bytes32 {\n fn fmt(&self, f: &", "error_type": "undefined_variable", "compile_error": "error: `<<` is interpreted as a start of generic arguments for `u8`, not a shift\n --> src/main.rs:13:41\n |\n13 | b[i / 2] |= (*c - 48) as u8 << ((8 * (i % 2)) as u8);\n | ^^ --- interpreted as generic arguments\n | |\n | not interpreted as shift\n |\nhelp: try shifting the cast value\n |\n13 | b[i / 2] |= ((*c - 48) as u8) << ((8 * (i % 2)) as u8);\n"}
23
- {"sample_index": 43, "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.", "code": "// Define a `Result` enum\nenum Result<T> {\n Ok(T),\n Err(String),\n}\n\n// Define a function that returns a `Result`\nfn get_number() -> Result<i32> {\n Err(\"Error\".to_string())\n}\n\nfn main() {\n // Example 1: Using `if let`\n let number = get_number();\n if let Ok(n) = number {\n println!(\"Got a number: {}\", n);\n } else {\n println!(\"Got an error\");\n }\n\n // Example 2: Using `match`\n let number = get_number();\n match number {\n Ok(n) => println!(\"Got a nu", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:9:5\n |\n8 | fn get_number() -> Result<i32> {\n | ----------- expected `Result<i32>` because of return type\n9 | Err(\"Error\".to_string())\n | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<i32>`, found `Result<_, String>`\n |\n = note: `std::result::Result<_, String>` and `Result<i32>` have similar names, but are actually distinct types\nnote: `std::result::Result<_, String>` is defined in crate `core`\n --> /rustc/ed61e7d7e242494"}
24
- {"sample_index": 47, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n let mut map = HashMap::new();\n map.insert(1, 10);\n map.insert(2, 20);\n map.insert(3, 30);\n\n let sum: u64 = map.iter().filter(|&(_, v)| *v < 25).map(|&(_, v)| v).sum();\n println!(\"{}\", sum);\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:9:62\n |\n9 | let sum: u64 = map.iter().filter(|&(_, v)| *v < 25).map(|&(_, v)| v).sum();\n | ^^^^^^^\n | |\n | expected `(&{integer}, &{integer})`, found `&_`\n | expected due to this\n |\n = note: expec"}
25
- {"sample_index": 48, "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.", "code": "use std::str::FromStr;\n\n#[derive(Debug)]\nstruct MyWrapper([u8; 32]);\n\nimpl FromStr for MyWrapper {\n type Err = String;\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(\"wrong length\".to_string());\n }\n let mut bytes = [0; 32];\n for (i, c) in s.bytes().enumerate() {\n if c!= b''{\n bytes[i] = c;\n }\n }\n Ok(MyWrapper(bytes))\n }\n}\n\nimpl std::fmt::Display for MyWrapper {\n ", "error_type": "other", "compile_error": "error: empty character literal\n --> src/main.rs:14:22\n |\n14 | if c!= b''{\n | ^ empty character literal\n\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
26
- {"sample_index": 51, "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.", "code": "#[derive(Debug)]\npub struct Bytes32([u8; 32]);\n\nimpl FromStr for Bytes32 {\n type Err = std::num::ParseIntError;\n\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n let bytes = hex::decode(s)?;\n if bytes.len()!= 32 {\n Err(std::num::ParseIntError::from_str_radix(\"\", 16))\n } else {\n Ok(Bytes32(bytes))\n }\n }\n}\n\nimpl std::fmt::Display for Bytes32 {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n let hex = hex", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:4:6\n |\n4 | impl FromStr for Bytes32 {\n | ^^^^^^^ not found in this scope\n |\nhelp: consider importing this trait\n |\n1 + use std::str::FromStr;\n |\n\nerror[E0433]: failed to resolve: use of unresolved module or unlinked crate `hex`\n --> src/main.rs:8:21\n |\n8 | let bytes = hex::decode(s)?;\n | ^^^ use of unresolved module or unlinked crate `hex`\n |\n = help: if you wanted to use a crate na"}
27
- {"sample_index": 52, "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.", "code": "fn main() {\n let numbers = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n let even_numbers = numbers.iter().filter(|&x| x % 2 == 0);\n let sum: u64 = even_numbers.map(|x| x as u64).sum();\n println!(\"{}\", sum);\n}", "error_type": "other", "compile_error": "error[E0606]: casting `&i32` as `u64` is invalid\n --> src/main.rs:4:41\n |\n4 | let sum: u64 = even_numbers.map(|x| x as u64).sum();\n | ^^^^^^^^\n |\nhelp: dereference the expression\n |\n4 | let sum: u64 = even_numbers.map(|x| *x as u64).sum();\n | +\n\nFor more information about this error, try `rustc --explain E0606`.\nerror: could not compile `app` (bin \"app\") due to 1 previous error\n"}
28
- {"sample_index": 54, "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.", "code": "use thiserror::Error;\nuse std::fmt;\n\n#[derive(Debug, Error, PartialEq)]\npub enum MyError {\n #[error(\"bad input: {0}\")]\n BadInput(String),\n\n #[error(\"no such file: {0}\")]\n NoSuchFile(String),\n}\n\nimpl fmt::Display for MyError {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n match self {\n Self::BadInput(s) => write!(f, \"bad input: {}\", s),\n Self::NoSuchFile(s) => write!(f, \"no such file: {}\", s),\n }\n }\n}\n\nfn read_file(filename: &st", "error_type": "other", "compile_error": "error[E0119]: conflicting implementations of trait `std::fmt::Display` for type `MyError`\n --> src/main.rs:4:17\n |\n 4 | #[derive(Debug, Error, PartialEq)]\n | ^^^^^ conflicting implementation for `MyError`\n...\n13 | impl fmt::Display for MyError {\n | ----------------------------- first implementation here\n |\n = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)\n\nFor more information about this error, try"}
29
- {"sample_index": 55, "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.", "code": "#[derive(Debug, PartialEq)]\npub struct U32Bytes(pub [u8; 32]);\n\nimpl std::str::FromStr for U32Bytes {\n type Err = String;\n fn from_str(s: &str) -> Result<Self, Self::Err> {\n if s.len()!= 32 {\n return Err(\"Input must be 32 characters long\".to_owned());\n }\n let mut buf = [0u8; 32];\n for (i, b) in buf.iter_mut().enumerate() {\n *b = s.as_bytes()[i] as u8;\n }\n Ok(U32Bytes(buf))\n }\n}\n\nimpl std::fmt::Display for U32Bytes {\n fn ", "error_type": "trait_error", "compile_error": "error[E0433]: failed to resolve: use of unresolved module or unlinked crate `hex`\n --> src/main.rs:20:25\n |\n20 | write!(f, \"{}\", hex::encode(self.0))\n | ^^^ use of unresolved module or unlinked crate `hex`\n |\n = help: if you wanted to use a crate named `hex`, use `cargo add hex` to add it to your `Cargo.toml`\n\nerror[E0599]: no function or associated item named `from_str` found for struct `U32Bytes` in the current scope\n --> src/main.rs:25:23\n |\n 2 | pu"}
30
- {"sample_index": 60, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n let mut map = HashMap::new();\n map.insert(1, 1);\n map.insert(2, 2);\n map.insert(3, 3);\n map.insert(4, 4);\n\n let sum = map.iter().filter(|&(_, &x)| x > 1).map(|&(_, &x)| x).sum::<i32>();\n println!(\"{}\", sum);\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:10:56\n |\n10 | let sum = map.iter().filter(|&(_, &x)| x > 1).map(|&(_, &x)| x).sum::<i32>();\n | ^^^^^^^^\n | |\n | expected `(&{integer}, &{integer})`, found `&_`\n | expected due to this\n |\n = note: expected tuple `"}
31
- {"sample_index": 62, "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.", "code": "use thiserror::Error;\n\n#[derive(thiserror::Error, Debug)]\npub enum Error {\n #[error(\"Invalid input: {0}\")]\n InvalidInput(String),\n #[error(\"IO error: {0}\")]\n IOError(std::io::Error),\n #[error(\"Other: {0}\")]\n Other(String),\n}\n\nfn main() {\n let result = do_it();\n match result {\n Ok(_) => (),\n Err(e) => println!(\"Error: {:?}\", e),\n }\n}\n\nfn do_it() -> Result<(), Error> {\n let input = \"foo\";\n let input_len = input.len();\n if input_len < 3 {\n re", "error_type": "type_mismatch", "compile_error": "warning: unused import: `thiserror::Error`\n --> src/main.rs:1:5\n |\n1 | use thiserror::Error;\n | ^^^^^^^^^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\nerror[E0061]: this function takes 2 arguments but 1 argument was supplied\n --> src/main.rs:29:13\n |\n29 | let _ = std::io::Read::read_to_string(&file).map_err(Error::IOError)?;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------- argument #2 of type `&mut String` is missing\n |\nnote: types"}
 
1
+ {"sample_index": 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 blo", "code": "use anyhow::anyhow;\nuse anyhow::Result;\nuse std::io;\n\nfn main() -> Result<()> {\n let x = 10;\n let y = 0;\n let z = x / y;\n\n match z {\n Ok(_) => Ok(()),\n Err(e) => Err(anyhow!(e)),\n }\n}", "error_type": "type_mismatch", "compile_error": "warning: unused import: `std::io`\n --> src/main.rs:3:5\n |\n3 | use std::io;\n | ^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nerror[E0308]: mismatched types\n --> src/main.rs:11:9\n |\n10 | match z {\n | - this expression has type `{integer}`\n11 | Ok(_) => Ok(()),\n | ^^^^^ expected integer, found `Result<_, _>`\n |\n = note: expected type `{integer}`\n found enum `Result<_, _>`\n\nerror[E0308]: mismatched types\n --> src/main.rs:12:9\n |\n10 | match z {\n | - this expression has type `{integer}`\n11 | Ok(_) => Ok(()),\n12 | Err(e) => Err(anyhow!(e)),\n | ^^^^^^ expected integer, found `Result<_, _>`\n |\n = note: expected type `{integer}`\n found enum `Result<_, _>`\n\nFor more information about this error, try `rustc --explain E0308`.\nerror: could not compile `template_app` (bin \"template_app\") due to 2 previous errors; 1 warning emitted\n"}
2
+ {"sample_index": 3, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n let v = vec![1, 2, 3, 4, 5];\n\n let mut map = HashMap::new();\n for i in v {\n map.entry(i).and_modify(|v| *v += 1).or_insert(i);\n }\n\n println!(\"{:?}\", map);\n\n let mut map = HashMap::new();\n for i in v {\n if let Some(v) = map.get_mut(&i) {\n *v += 1;\n } else {\n map.insert(i, 1);\n }\n }\n\n println!(\"{:?}\", map);\n}", "error_type": "other", "compile_error": "error[E0382]: use of moved value: `v`\n --> src/main.rs:14:14\n |\n4 | let v = vec![1, 2, 3, 4, 5];\n | - move occurs because `v` has type `Vec<i32>`, which does not implement the `Copy` trait\n...\n7 | for i in v {\n | - `v` moved due to this implicit call to `.into_iter()`\n...\n14 | for i in v {\n | ^ value used here after move\n |\nnote: `into_iter` takes ownership of the receiver `self`, which moves `v`\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/collect.rs:346:18\nhelp: consider iterating over a slice of the `Vec<i32>`'s content to avoid moving into the `for` loop\n |\n7 | for i in &v {\n | +\n\nFor more information about this error, try `rustc --explain E0382`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
3
+ {"sample_index": 4, "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.", "code": "use uuid::Uuid;\n\nfn main() {\n let random_uuid = Uuid::new_v4();\n println!(\"Random UUID: {}\", random_uuid);\n\n let v4_uuid = Uuid::new_v4();\n println!(\"V4 UUID: {}\", v4_uuid);\n\n let v5_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\");\n println!(\"V5 UUID: {}\", v5_uuid);\n\n let v5_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\");\n println!(\"V5 UUID: {}\", v5_uuid);\n}", "error_type": "other", "compile_error": "error[E0599]: no function or associated item named `new_v5` found for struct `Uuid` in the current scope\n --> src/main.rs:10:25\n |\n10 | let v5_uuid = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\");\n | ^^^^^^ function or associated item not found in `Uuid`\n |\nnote: if you're trying to build a new `Uuid` consider using one of the following associated functions:\n uuid::builder::<impl Uuid>::nil\n uuid::builder::<impl Uuid>::max\n uuid::builder::<impl Uuid>::from_fields\n uuid::builder::<impl Uuid>::from_fields_le\n and 11 others\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/uuid-1.18.1/src/builder.rs:72:5\n |\n72 | pub const fn nil() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n98 | pub const fn max() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n122 | pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8; 8]) -> Uuid {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}
4
+ {"sample_index": 5, "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.", "code": "use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc};\n\nfn format_date(date: &str) -> String {\n let date: DateTime<Utc> = date.parse().unwrap();\n let date = NaiveDate::from_ymd(date.year(), date.month(), date.day());\n let formatted = format!(\"{}-{:02}-{:02}\", date.year(), date.month(), date.day());\n return formatted;\n}\n\nfn main() {\n let date = \"2019-01-01\";\n let formatted = format_date(date);\n println!(\"{}\", formatted);\n}", "error_type": "other", "compile_error": "warning: unused import: `NaiveDateTime`\n --> src/main.rs:1:35\n |\n1 | use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc};\n | ^^^^^^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nwarning: use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead\n --> src/main.rs:5:27\n |\n5 | let date = NaiveDate::from_ymd(date.year(), date.month(), date.day());\n | ^^^^^^^^\n |\n = note: `#[warn(deprecated)]` on by default\n\nerror[E0599]: no method named `year` found for struct `DateTime` in the current scope\n --> src/main.rs:5:41\n |\n5 | let date = NaiveDate::from_ymd(date.year(), date.month(), date.day());\n | ^^^^\n |\n ::: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.42/src/traits.rs:33:8\n |\n33 | fn year(&self) -> i32;\n | ---- the method is available for `DateTime<Utc>` here\n |\n = he"}
5
+ {"sample_index": 8, "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.", "code": "use chrono::{DateTime, DateTime, Local};\nuse chrono::format::Pf;\n\nfn main() {\n let date = DateTime::parse_from_str(\"2020-01-01 12:30\", \"%Y-%m-%d %H:%M\").unwrap();\n let formatted = date.format(\"%Y/%m/%d\").to_string();\n\n let date = DateTime::parse_from_str(\"2020-01-01 12:30\", \"%Y-%m-%d %H:%M\").unwrap();\n let formatted = date.format(\"%a %b %e %Y\").to_string();\n\n let date = DateTime::parse_from_str(\"2020-01-01 12:30\", \"%Y-%m-%d %H:%M\").unwrap();\n let formatted = date.format(\"%a %b ", "error_type": "other", "compile_error": "error[E0252]: the name `DateTime` is defined multiple times\n --> src/main.rs:1:24\n |\n1 | use chrono::{DateTime, DateTime, Local};\n | -------- ^^^^^^^^--\n | | |\n | | `DateTime` reimported here\n | | help: remove unnecessary import\n | previous import of the type `DateTime` here\n |\n = note: `DateTime` must be defined only once in the type namespace of this module\n\nerror[E0432]: unresolved import `chrono::format::Pf`\n --> src/main.rs:2:5\n |\n2 | use chrono::format::Pf;\n | ^^^^^^^^^^^^^^^^^^ no `Pf` in `format`\n\nwarning: unused imports: `DateTime` and `Local`\n --> src/main.rs:1:24\n |\n1 | use chrono::{DateTime, DateTime, Local};\n | ^^^^^^^^ ^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nwarning: unused variable: `formatted`\n --> src/main.rs:6:9\n |\n6 | let formatted = date.format(\"%Y/%m/%d\").to_string();\n | ^^^^^^^^^ help: if this is inten"}
6
+ {"sample_index": 9, "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.", "code": "use serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct MyStruct {\n name: String,\n value: f64,\n}\n\nfn main() {\n let data = MyStruct {\n name: \"Example\".to_string(),\n value: 5.0,\n };\n\n let json = serde_json::to_string(&data).unwrap();\n println!(\"JSON: {}\", json);\n\n let new_data: MyStruct = serde_json::from_str(&json).unwrap();\n println!(\"New data: {:?}\", new_data);\n}", "error_type": "trait_error", "compile_error": "error[E0277]: `MyStruct` doesn't implement `Debug`\n --> src/main.rs:19:32\n |\n19 | println!(\"New data: {:?}\", new_data);\n | ^^^^^^^^ `MyStruct` cannot be formatted using `{:?}`\n |\n = help: the trait `Debug` is not implemented for `MyStruct`\n = note: add `#[derive(Debug)]` to `MyStruct` or manually `impl Debug for MyStruct`\n = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)\nhelp: consider annotating `MyStruct` with `#[derive(Debug)]`\n |\n4 + #[derive(Debug)]\n5 | struct MyStruct {\n |\n\nFor more information about this error, try `rustc --explain E0277`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
7
+ {"sample_index": 12, "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.", "code": "#[derive(Debug)]\nstruct Point {\n x: f64,\n y: f64,\n}\n\nimpl Point {\n fn new(x: f64, y: f64) -> Self {\n Self { x, y }\n }\n}\n\nimpl Point {\n fn distance(&self, other: &Self) -> f64 {\n ((self.x - other.x).powi(2) + (self.y - other.y).powi(2)).sqrt()\n }\n\n fn get_x(&self) -> f64 {\n self.x\n }\n\n fn get_y(&self) -> f64 {\n self.y\n }\n\n fn set_x(&mut self, x: f64) {\n self.x = x;\n }\n\n fn set_y(&mut self, y: f64) {\n self.y = y;\n ", "error_type": "borrow_checker", "compile_error": "error[E0507]: cannot move out of `*self` which is behind a shared reference\n --> src/main.rs:41:9\n |\n41 | *self\n | ^^^^^ move occurs because `*self` has type `Point`, which does not implement the `Copy` trait\n |\nnote: if `Point` implemented `Clone`, you could clone the value\n --> src/main.rs:2:1\n |\n2 | struct Point {\n | ^^^^^^^^^^^^ consider implementing `Clone` for this type\n...\n41 | *self\n | ----- you could clone this value\n\nerror[E0596]: cannot borrow `p1` as mutable, as it is not declared as mutable\n --> src/main.rs:46:9\n |\n46 | let p1 = Point::new(1.0, 2.0);\n | ^^ not mutable\n...\n51 | p1.set_x(5.0);\n | -- cannot borrow as mutable\n52 | p1.set_y(6.0);\n | -- cannot borrow as mutable\n |\nhelp: consider changing this to be mutable\n |\n46 | let mut p1 = Point::new(1.0, 2.0);\n | +++\n\nSome errors have detailed explanations: E0507, E0596.\nFor more information about an error, try `rustc --exp"}
8
+ {"sample_index": 14, "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.", "code": "use serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct Person {\n first_name: String,\n last_name: String,\n age: u8,\n address: Address,\n}\n\n#[derive(Serialize, Deserialize)]\nstruct Address {\n street: String,\n city: String,\n country: String,\n}\n\nfn main() {\n let person = Person {\n first_name: String::from(\"John\"),\n last_name: String::from(\"Doe\"),\n age: 30,\n address: Address {\n street: String::from(\"123 Main St\"),\n ", "error_type": "trait_error", "compile_error": "error[E0277]: `Person` doesn't implement `Debug`\n --> src/main.rs:34:36\n |\n34 | println!(\"Deserialized: {:?}\", deserialized);\n | ^^^^^^^^^^^^ `Person` cannot be formatted using `{:?}`\n |\n = help: the trait `Debug` is not implemented for `Person`\n = note: add `#[derive(Debug)]` to `Person` or manually `impl Debug for Person`\n = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)\n\nFor more information about this error, try `rustc --explain E0277`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
9
+ {"sample_index": 18, "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.", "code": "use uuid::Uuid;\n\nfn main() {\n println!(\"{}\", Uuid::new_v4());\n println!(\"{}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\"));\n println!(\"{}\", Uuid::parse_str(\"f47ac10b-58cc-4372-a567-0a9c71c29dd1\").unwrap());\n let mut uuid = Uuid::new_v4();\n uuid.set_version(5);\n uuid.set_variant(Uuid::Variant::RFC4122);\n uuid.set_variant(Uuid::Variant::RFC4122);\n println!(\"{}\", uuid);\n}", "error_type": "trait_error", "compile_error": "error[E0599]: no function or associated item named `new_v5` found for struct `Uuid` in the current scope\n --> src/main.rs:5:26\n |\n5 | println!(\"{}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\"));\n | ^^^^^^ function or associated item not found in `Uuid`\n |\nnote: if you're trying to build a new `Uuid` consider using one of the following associated functions:\n uuid::builder::<impl Uuid>::nil\n uuid::builder::<impl Uuid>::max\n uuid::builder::<impl Uuid>::from_fields\n uuid::builder::<impl Uuid>::from_fields_le\n and 11 others\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/uuid-1.18.1/src/builder.rs:72:5\n |\n72 | pub const fn nil() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n98 | pub const fn max() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n122 | pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8; 8]) -> Uuid {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}
10
+ {"sample_index": 19, "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.", "code": "use chrono::{DateTime, NaiveDateTime, Utc};\n\nfn main() {\n let dt = NaiveDateTime::parse_from_str(\"2020-01-01 00:00:00\", \"%Y-%m-%d %H:%M:%S\").unwrap();\n let formatted = Utc.ymd(dt.year(), dt.month(), dt.day()).to_string();\n println!(\"{}\", formatted);\n\n let dt = NaiveDateTime::parse_from_str(\"2020-01-01 00:00:00\", \"%Y-%m-%d %H:%M:%S\").unwrap();\n let formatted = Utc.ymd(dt.year(), dt.month(), dt.day()).format(\"%a %b %e %Y\").to_string();\n println!(\"{}\", formatted);\n\n let dt = Na", "error_type": "trait_error", "compile_error": "warning: unused import: `DateTime`\n --> src/main.rs:1:14\n |\n1 | use chrono::{DateTime, NaiveDateTime, Utc};\n | ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nerror[E0599]: no method named `ymd` found for struct `Utc` in the current scope\n --> src/main.rs:5:25\n |\n5 | let formatted = Utc.ymd(dt.year(), dt.month(), dt.day()).to_string();\n | ^^^ method not found in `Utc`\n |\n ::: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.42/src/offset/mod.rs:335:8\n |\n335 | fn ymd(&self, year: i32, month: u32, day: u32) -> Date<Self> {\n | --- the method is available for `Utc` here\n |\n = help: items from traits can only be used if the trait is in scope\nhelp: trait `TimeZone` which provides `ymd` is implemented but not in scope; perhaps you want to import it\n |\n1 + use chrono::TimeZone;\n |\n\nerror[E0599]: no method named `year` found for struct `NaiveDateTime` in the current "}
11
+ {"sample_index": 20, "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.", "code": "use uuid::Uuid;\n\nfn main() {\n println!(\"{}\", Uuid::new_v4());\n println!(\"{}\", Uuid::new_v5(\"example.com\", \"rust\"));\n println!(\"{}\", Uuid::parse_str(\"f47ac10b-58cc-4372-a567-0a9c71e4a667\"));\n}", "error_type": "trait_error", "compile_error": "error[E0599]: no function or associated item named `new_v5` found for struct `Uuid` in the current scope\n --> src/main.rs:5:26\n |\n5 | println!(\"{}\", Uuid::new_v5(\"example.com\", \"rust\"));\n | ^^^^^^ function or associated item not found in `Uuid`\n |\nnote: if you're trying to build a new `Uuid` consider using one of the following associated functions:\n uuid::builder::<impl Uuid>::nil\n uuid::builder::<impl Uuid>::max\n uuid::builder::<impl Uuid>::from_fields\n uuid::builder::<impl Uuid>::from_fields_le\n and 11 others\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/uuid-1.18.1/src/builder.rs:72:5\n |\n72 | pub const fn nil() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n98 | pub const fn max() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n122 | pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8; 8]) -> Uuid {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}
12
+ {"sample_index": 21, "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.", "code": "use std::fs;\n\nfn main() {\n let input = fs::read_to_string(\"input.txt\").unwrap();\n let numbers: Vec<i32> = input.lines()\n .map(|line| line.parse::<i32>().unwrap())\n .collect();\n let sum: i32 = numbers.iter()\n .filter(|&x| x > 0)\n .sum();\n println!(\"{}\", sum);\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:9:25\n |\n9 | .filter(|&x| x > 0)\n | ^ expected `&i32`, found integer\n |\nhelp: consider dereferencing the borrow\n |\n9 | .filter(|&x| *x > 0)\n | +\n\nFor more information about this error, try `rustc --explain E0308`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
13
+ {"sample_index": 22, "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.", "code": "use chrono::{DateTime, Datelike, Local, Timelike, Utc};\n\nfn main() {\n let date = \"2020-07-26T16:05:56Z\";\n let date = DateTime::<Utc>::parse_from_rfc3339(date).unwrap();\n let formatted = date.with_timezone(&Local).format(\"%B %e %Y\").to_string();\n println!(\"{}\", formatted);\n\n let date = \"2020-07-26T16:05:56Z\";\n let date = DateTime::<Utc>::parse_from_rfc3339(date).unwrap();\n let formatted = date.with_timezone(&Local).format(\"%B %e %Y\").to_string();\n println!(\"{}\", formatted)", "error_type": "other", "compile_error": "warning: unused imports: `Datelike` and `Timelike`\n --> src/main.rs:1:24\n |\n1 | use chrono::{DateTime, Datelike, Local, Timelike, Utc};\n | ^^^^^^^^ ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nerror[E0599]: no function or associated item named `parse_from_rfc3339` found for struct `DateTime<Utc>` in the current scope\n --> src/main.rs:5:33\n |\n5 | let date = DateTime::<Utc>::parse_from_rfc3339(date).unwrap();\n | ^^^^^^^^^^^^^^^^^^ function or associated item not found in `DateTime<Utc>`\n |\nnote: if you're trying to build a new `DateTime<Utc>` consider using one of the following associated functions:\n DateTime::<Tz>::from_naive_utc_and_offset\n DateTime::<Tz>::from_utc\n DateTime::<Tz>::from_local\n DateTime::<Utc>::from_timestamp_secs\n and 4 others\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.42/src/datetime/mod.rs:94:5\n |\n94 |"}
14
+ {"sample_index": 24, "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 blo", "code": "use anyhow::Result;\n\nfn main() -> Result<()> {\n let a: Result<String, std::num::ParseIntError> = \"a\".parse::<i32>();\n let b: Result<String, std::io::Error> = std::fs::read_to_string(\"nonexistent\");\n let c: Result<(), std::env::VarError> = std::env::var(\"nonexistent\");\n let d: Result<(), anyhow::Error> = Err(anyhow::anyhow!(\"oh no\"));\n\n a?;\n b?;\n c?;\n d?;\n\n Ok(())\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:4:54\n |\n4 | let a: Result<String, std::num::ParseIntError> = \"a\".parse::<i32>();\n | --------------------------------------- ^^^^^^^^^^^^^^^^^^ expected `Result<String, ParseIntError>`, found `Result<i32, ParseIntError>`\n | |\n | expected due to this\n |\n = note: expected enum `Result<String, _>`\n found enum `Result<i32, _>`\n\nerror[E0308]: mismatched types\n --> src/main.rs:6:45\n |\n6 | let c: Result<(), std::env::VarError> = std::env::var(\"nonexistent\");\n | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<(), VarError>`, found `Result<String, VarError>`\n | |\n | expected due to this\n |\n = note: expected enum `Result<(), _>`\n found enum `Result<String, _>`\n\nFor more information about this error, try `rustc --explain E0308`.\nerror: could not compile `template_app` (bin \"template_app\") due to 2 previous err"}
15
+ {"sample_index": 25, "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.", "code": "use serde_derive::{Deserialize, Serialize};\nuse serde_json;\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: 20,\n };\n\n let json = serde_json::to_string(&person).unwrap();\n\n println!(\"JSON: {}\", json);\n\n let deserialized: Person = serde_json::from_str(&json).unwrap();\n println!(\"Deserialized: {:?}\", deserialized);\n}", "error_type": "trait_error", "compile_error": "error[E0432]: unresolved import `serde_derive`\n --> src/main.rs:1:5\n |\n1 | use serde_derive::{Deserialize, Serialize};\n | ^^^^^^^^^^^^ use of undeclared crate or module `serde_derive`\n\nerror[E0277]: the trait bound `Person: serde::Serialize` is not satisfied\n --> src/main.rs:16:38\n |\n16 | let json = serde_json::to_string(&person).unwrap();\n | --------------------- ^^^^^^^ the trait `serde::Serialize` is not implemented for `Person`\n | |\n | required by a bound introduced by this call\n |\n = note: for local types consider adding `#[derive(serde::Serialize)]` to your `Person` type\n = note: for types from other crates check whether the crate offers a `serde` feature flag\n = help: the following other types implement trait `serde::Serialize`:\n &'a T\n &'a mut T\n ()\n (T,)\n (T0, T1)\n (T0, T1, T2)\n (T0, T1, T2"}
16
+ {"sample_index": 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.", "code": "use thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum MyError {\n #[error(transparent)]\n IoError(#[from] std::io::Error),\n #[error(transparent)]\n OtherError(#[from] String),\n}\n\nfn do_some_io() -> Result<(), MyError> {\n let _ = std::fs::File::open(\"some_file.txt\")?;\n Ok(())\n}\n\nfn main() {\n if let Err(err) = do_some_io() {\n println!(\"Error: {}\", err);\n }\n}", "error_type": "other", "compile_error": "error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied\n --> src/main.rs:7:13\n |\n7 | #[error(transparent)]\n | ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds\n |\n = note: the following trait bounds were not satisfied:\n `String: std::error::Error`\n which is required by `String: AsDynError<'_>`\n `&String: std::error::Error`\n which is required by `&String: AsDynError<'_>`\n `str: Sized`\n which is required by `str: AsDynError<'_>`\n `str: std::error::Error`\n which is required by `str: AsDynError<'_>`\n\nFor more information about this error, try `rustc --explain E0599`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
17
+ {"sample_index": 30, "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.", "code": "use uuid::Uuid;\n\nfn main() {\n // generate a random UUID\n let random_uuid = Uuid::new_v4();\n println!(\"Random UUID: {:?}\", random_uuid);\n\n // generate a random UUID with a namespace\n let random_uuid_with_namespace = Uuid::new_v4_with_namespace(\n &Uuid::NAMESPACE_DNS,\n &Uuid::new_v4(),\n );\n println!(\"Random UUID with namespace: {:?}\", random_uuid_with_namespace);\n\n // generate a random UUID based on a string\n let random_uuid_from_string = Uuid::parse_str(\"0", "error_type": "other", "compile_error": "error[E0599]: no function or associated item named `new_v4_with_namespace` found for struct `Uuid` in the current scope\n --> src/main.rs:9:44\n |\n9 | let random_uuid_with_namespace = Uuid::new_v4_with_namespace(\n | ^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `Uuid`\n |\nnote: if you're trying to build a new `Uuid` consider using one of the following associated functions:\n uuid::builder::<impl Uuid>::nil\n uuid::builder::<impl Uuid>::max\n uuid::builder::<impl Uuid>::from_fields\n uuid::builder::<impl Uuid>::from_fields_le\n and 11 others\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/uuid-1.18.1/src/builder.rs:72:5\n |\n72 | pub const fn nil() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n98 | pub const fn max() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n122 | pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8; 8]) -> Uuid {\n |"}
18
+ {"sample_index": 32, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n let numbers = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n let map: HashMap<char, i32> = vec!['a', 'b', 'c', 'd', 'e'].into_iter().zip(1..10).collect();\n\n let sum: i32 = numbers.iter()\n .filter(|&x| map.contains_key(&x))\n .map(|x| x * map[&x])\n .sum();\n \n println!(\"{}\", sum);\n}", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:8:38\n |\n8 | .filter(|&x| map.contains_key(&x))\n | ------------ ^^ expected `&char`, found `&&{integer}`\n | |\n | arguments to this method are incorrect\n |\n = note: expected reference `&char`\n found reference `&&{integer}`\nnote: method defined here\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/collections/hash/map.rs:1040:12\n\nerror[E0308]: mismatched types\n --> src/main.rs:9:25\n |\n9 | .map(|x| x * map[&x])\n | ^^ expected `&char`, found `&&{integer}`\n |\n = note: expected reference `&char`\n found reference `&&{integer}`\n\nFor more information about this error, try `rustc --explain E0308`.\nerror: could not compile `template_app` (bin \"template_app\") due to 2 previous errors\n"}
19
+ {"sample_index": 36, "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.", "code": "use rand::prelude::*;\n\nfn main() {\n let mut rng = thread_rng();\n let mut numbers: Vec<i32> = (0..10).collect();\n\n println!(\"Random numbers: {:?}\", numbers);\n println!(\"Random number: {}\", random_item(&mut rng, &numbers));\n}\n\nfn random_item<T: Rng, U: Iterator<Item = T>>(rng: &mut T, iterator: &mut U) -> T::Item {\n iterator.choose(rng).unwrap()\n}", "error_type": "type_mismatch", "compile_error": "error[E0220]: associated type `Item` not found for `T`\n --> src/main.rs:11:84\n |\n11 | fn random_item<T: Rng, U: Iterator<Item = T>>(rng: &mut T, iterator: &mut U) -> T::Item {\n | ^^^^ associated type `Item` not found\n\nerror[E0308]: mismatched types\n --> src/main.rs:8:57\n |\n8 | println!(\"Random number: {}\", random_item(&mut rng, &numbers));\n | ----------- ^^^^^^^^ types differ in mutability\n | |\n | arguments to this function are incorrect\n |\n = note: expected mutable reference `&mut _`\n found reference `&Vec<i32>`\nnote: function defined here\n --> src/main.rs:11:4\n |\n11 | fn random_item<T: Rng, U: Iterator<Item = T>>(rng: &mut T, iterator: &mut U) -> T::Item {\n | ^^^^^^^^^^^ ----------------\n\nSome erro"}
20
+ {"sample_index": 37, "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.", "code": "use chrono::{NaiveDate, NaiveDateTime, NaiveTime, Utc};\n\nfn main() {\n // Parse a date string\n let date_string = \"2021-01-01 12:00:00\";\n let date = NaiveDate::parse_from_str(date_string, \"%Y-%m-%d %H:%M:%S\").unwrap();\n\n // Parse a datetime string\n let datetime_string = \"2021-01-01 12:00:00\";\n let datetime = NaiveDateTime::parse_from_str(datetime_string, \"%Y-%m-%d %H:%M:%S\").unwrap();\n\n // Format the date\n let formatted_date = date.format(\"%Y/%m/%d\").to_string();\n printl", "error_type": "other", "compile_error": "warning: unused imports: `NaiveTime` and `Utc`\n --> src/main.rs:1:40\n |\n1 | use chrono::{NaiveDate, NaiveDateTime, NaiveTime, Utc};\n | ^^^^^^^^^ ^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nerror[E0624]: method `year` is private\n --> src/main.rs:26:21\n |\n26 | let year = date.year();\n | ^^^^ private method\n |\n ::: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.42/src/naive/date/mod.rs:1380:5\n |\n1380 | const fn year(&self) -> i32 {\n | --------------------------- private method defined here\n |\n = help: items from traits can only be used if the trait is in scope\nhelp: trait `Datelike` which provides `year` is implemented but not in scope; perhaps you want to import it\n |\n1 + use chrono::Datelike;\n |\n\nerror[E0624]: method `month` is private\n --> src/main.rs:30:22\n |\n30 | let month = date.month();\n | "}
21
+ {"sample_index": 41, "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.", "code": "use std::iter;\n\nfn main() {\n let numbers: Vec<i32> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];\n let sum: i32 = iter::filter(numbers.iter(), |&x| x % 2 == 0)\n .map(|x| x * 3)\n .sum();\n println!(\"{}\", sum);\n}", "error_type": "other", "compile_error": "error[E0425]: cannot find function `filter` in module `iter`\n --> src/main.rs:5:26\n |\n5 | let sum: i32 = iter::filter(numbers.iter(), |&x| x % 2 == 0)\n | ^^^^^^ not found in `iter`\n\nFor more information about this error, try `rustc --explain E0425`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
22
+ {"sample_index": 43, "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.", "code": "use rand::Rng;\n\nfn main() {\n let mut rng = rand::thread_rng();\n\n let random_number = rng.gen::<i32>();\n println!(\"Random number: {}\", random_number);\n\n let mut rng = rand::thread_rng();\n let random_item: &str = random_item(&[\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\"]);\n\n println!(\"Random item: {}\", random_item);\n\n let mut rng = rand::thread_rng();\n let random_item: &str = random_item(&[\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\", \"fig\", \"grape\"]);\n\n print", "error_type": "other", "compile_error": "error[E0106]: missing lifetime specifier\n --> src/main.rs:30:35\n |\n30 | fn random_item(items: &[&str]) -> &str {\n | ------- ^ expected named lifetime parameter\n |\n = help: this function's return type contains a borrowed value, but the signature does not say which one of `items`'s 2 lifetimes it is borrowed from\nhelp: consider introducing a named lifetime parameter\n |\n30 | fn random_item<'a>(items: &'a [&'a str]) -> &'a str {\n | ++++ ++ ++ ++\n\nFor more information about this error, try `rustc --explain E0106`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
23
+ {"sample_index": 44, "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.", "code": "use std::ops::Deref;\n\nstruct Vector {\n x: i32,\n y: i32,\n}\n\nimpl Vector {\n fn new(x: i32, y: i32) -> Vector {\n Vector { x, y }\n }\n\n fn magnitude(&self) -> f64 {\n self.x as f64 * self.x as f64 + self.y as f64 * self.y as f64\n }\n}\n\nimpl Deref for Vector {\n type Target = (i32, i32);\n\n fn deref(&self) -> &Self::Target {\n (&self.x, &self.y)\n }\n}\n\nfn main() {\n let v = Vector::new(3, 4);\n println!(\"Magnitude of vector: {}\", v.magnitude());\n printl", "error_type": "type_mismatch", "compile_error": "error[E0308]: mismatched types\n --> src/main.rs:22:9\n |\n21 | fn deref(&self) -> &Self::Target {\n | ------------- expected `&(i32, i32)` because of return type\n22 | (&self.x, &self.y)\n | ^^^^^^^^^^^^^^^^^^ expected `&(i32, i32)`, found `(&i32, &i32)`\n |\n = note: expected reference `&(_, _)`\n found tuple `(&_, &_)`\n\nFor more information about this error, try `rustc --explain E0308`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
24
+ {"sample_index": 47, "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.", "code": "use std::collections::HashMap;\n\nfn main() {\n let mut numbers = HashMap::new();\n numbers.insert(\"one\".to_string(), 1);\n numbers.insert(\"two\".to_string(), 2);\n numbers.insert(\"three\".to_string(), 3);\n\n let sum = numbers\n .iter()\n .filter(|(_, v) => v % 2 == 0)\n .map(|(_, v) => v)\n .sum::<i32>();\n\n println!(\"The sum of even numbers is: {}\", sum);\n}", "error_type": "type_mismatch", "compile_error": "error: expected one of `,`, `:`, or `|`, found `=>`\n --> src/main.rs:11:24\n |\n11 | .filter(|(_, v) => v % 2 == 0)\n | ^^ expected one of `,`, `:`, or `|`\n\nerror: expected one of `!`, `#`, `&`, `(`, `,`, `-`, `...`, `..=`, `..`, `:`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `=>`\n --> src/main.rs:11:24\n |\n11 | .filter(|(_, v) => v % 2 == 0)\n | ^^ expected one of 18 possible tokens\n\nerror: could not compile `template_app` (bin \"template_app\") due to 2 previous errors\n"}
25
+ {"sample_index": 49, "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.", "code": "use thiserror::Error;\n\n#[derive(Debug, Error, Display)]\npub enum MyError {\n #[error(\"Not Found\")]\n NotFound,\n #[error(\"Invalid Url\")]\n InvalidUrl,\n #[error(\"IO Error\")]\n IOError,\n #[error(\"Other\")]\n Other(String),\n}\n\nfn fetch_url(url: &str) -> Result<String, MyError> {\n if url == \"https://www.google.com\" {\n Ok(\"Google\".to_string())\n } else {\n Err(MyError::NotFound)\n }\n}\n\nfn main() -> Result<(), MyError> {\n let url = \"https://www.google.com\";\n ", "error_type": "undefined_variable", "compile_error": "error: cannot find derive macro `Display` in this scope\n --> src/main.rs:3:24\n |\n3 | #[derive(Debug, Error, Display)]\n | ^^^^^^^\n\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error\n"}
26
+ {"sample_index": 50, "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.", "code": "use uuid::Uuid;\n\nfn main() {\n let uuid_v4 = Uuid::new_v4();\n let uuid_v5 = Uuid::new_v5(Uuid::NAMESPACE_OID, \"rust\");\n let uuid_v6 = Uuid::new_v6();\n let uuid_v7 = Uuid::new_v7();\n\n println!(\"v4: {:?}\", uuid_v4);\n println!(\"v5: {:?}\", uuid_v5);\n println!(\"v6: {:?}\", uuid_v6);\n println!(\"v7: {:?}\", uuid_v7);\n}", "error_type": "other", "compile_error": "error[E0599]: no function or associated item named `new_v5` found for struct `Uuid` in the current scope\n --> src/main.rs:5:25\n |\n5 | let uuid_v5 = Uuid::new_v5(Uuid::NAMESPACE_OID, \"rust\");\n | ^^^^^^ function or associated item not found in `Uuid`\n |\nnote: if you're trying to build a new `Uuid` consider using one of the following associated functions:\n uuid::builder::<impl Uuid>::nil\n uuid::builder::<impl Uuid>::max\n uuid::builder::<impl Uuid>::from_fields\n uuid::builder::<impl Uuid>::from_fields_le\n and 11 others\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/uuid-1.18.1/src/builder.rs:72:5\n |\n72 | pub const fn nil() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n98 | pub const fn max() -> Self {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n...\n122 | pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8; 8]) -> Uuid {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"}
27
+ {"sample_index": 51, "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.", "code": "use serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct User {\n name: String,\n age: u8,\n}\n\nfn main() {\n let user = User {\n name: \"John\".to_string(),\n age: 30,\n };\n\n let serialized_user = serde_json::to_string(&user).unwrap();\n\n let deserialized_user: User = serde_json::from_str(&serialized_user).unwrap();\n\n println!(\"User: {:?}\", user);\n println!(\"Serialized: {}\", serialized_user);\n println!(\"Deserialized: {:?}\", deserialized_user);", "error_type": "trait_error", "compile_error": "error[E0277]: `User` doesn't implement `Debug`\n --> src/main.rs:19:28\n |\n19 | println!(\"User: {:?}\", user);\n | ^^^^ `User` cannot be formatted using `{:?}`\n |\n = help: the trait `Debug` is not implemented for `User`\n = note: add `#[derive(Debug)]` to `User` or manually `impl Debug for User`\n = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)\nhelp: consider annotating `User` with `#[derive(Debug)]`\n |\n4 + #[derive(Debug)]\n5 | struct User {\n |\n\nerror[E0277]: `User` doesn't implement `Debug`\n --> src/main.rs:21:36\n |\n21 | println!(\"Deserialized: {:?}\", deserialized_user);\n | ^^^^^^^^^^^^^^^^^ `User` cannot be formatted using `{:?}`\n |\n = help: the trait `Debug` is not implemented for `User`\n = note: add `#[derive(Debug)]` to `User` or manually `impl Debug for"}