{"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 uuid1 = Uuid::new_v4();\n println!(\"uuid1: {}\", uuid1);\n\n let uuid2 = Uuid::new_v5(&Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\"));\n println!(\"uuid2: {}\", uuid2);\n\n let uuid3 = Uuid::new_v5(&Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\").unwrap());\n println!(\"uuid3: {}\", uuid3);\n\n let uuid4 = Uuid::new_v4();\n println!(\"uuid4: {}\", uuid4);\n\n let uuid5 = Uuid::new_v5(&Uuid::parse_str(\"00000000-0000-0000-0000-00000000000", "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:7:23\n |\n7 | let uuid2 = Uuid::new_v5(&Uuid::parse_str(\"00000000-0000-0000-0000-000000000000\"));\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::::nil\n uuid::builder::::max\n uuid::builder::::from_fields\n uuid::builder::::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 | ^^^^^^^^^^^^^^^^^^^^^^^^"} {"sample_index": 6, "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 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\ntrait Add {\n fn add(&self, other: Self) -> Self;\n}\n\nimpl Add for Point {\n fn add(&self, other: Self) -> Self {\n Self::new(self.x + other.x, self.y + other.y)\n }\n}\n\nfn main() {\n let p1 = Point::new(1.0, 2.0);\n let p2 = Point::new(3.0, 4.0);\n let p3 = p1.add(p2);\n println!(\"{:?}\", p3);\n}", "error_type": "trait_error", "compile_error": "error[E0277]: `Point` doesn't implement `Debug`\n --> src/main.rs:26:22\n |\n26 | println!(\"{:?}\", p3);\n | ^^ `Point` cannot be formatted using `{:?}`\n |\n = help: the trait `Debug` is not implemented for `Point`\n = note: add `#[derive(Debug)]` to `Point` or manually `impl Debug for Point`\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 `Point` with `#[derive(Debug)]`\n |\n1 + #[derive(Debug)]\n2 | struct Point {\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"} {"sample_index": 8, "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}\n\nfn main() {\n let person = Person {\n first_name: \"John\".to_string(),\n last_name: \"Doe\".to_string(),\n age: 25,\n };\n\n let json = serde_json::to_string(&person).unwrap();\n println!(\"{}\", json);\n\n let person: Person = serde_json::from_str(&json).unwrap();\n println!(\"{:?}\", person);\n}", "error_type": "trait_error", "compile_error": "error[E0277]: `Person` doesn't implement `Debug`\n --> src/main.rs:21:22\n |\n21 | println!(\"{:?}\", person);\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)\nhelp: consider annotating `Person` with `#[derive(Debug)]`\n |\n4 + #[derive(Debug)]\n5 | struct Person {\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"} {"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 std::io;\n\n#[derive(thiserror::Error, Debug)]\nenum Error {\n #[error(\"IoError: {0}\")]\n Io(io::Error),\n #[error(\"OtherError: {0}\")]\n Other(String),\n}\n\nfn main() -> Result<(), Error> {\n let _ = try {\n let _ = io::Error::last_os_error();\n Ok(())\n }?;\n\n let _ = try {\n let _ = String::from(\"error\");\n Ok(())\n }?;\n\n Ok(())\n}", "error_type": "other", "compile_error": "error[E0658]: `try` expression is experimental\n --> src/main.rs:12:13\n |\n12 | let _ = try {\n | _____________^\n13 | | let _ = io::Error::last_os_error();\n14 | | Ok(())\n15 | | }?;\n | |_____^\n |\n = note: see issue #31436 for more information\n\nerror[E0658]: `try` expression is experimental\n --> src/main.rs:17:13\n |\n17 | let _ = try {\n | _____________^\n18 | | let _ = String::from(\"error\");\n19 | | Ok(())\n20 | | }?;\n | |_____^\n |\n = note: see issue #31436 for more information\n\nerror[E0282]: type annotations needed\n --> src/main.rs:14:9\n |\n14 | Ok(())\n | ^^ cannot infer type of the type parameter `E` declared on the enum `Result`\n |\nhelp: consider specifying the generic arguments\n |\n14 | Ok::<(), E>(())\n | +++++++++\n\nSome errors have detailed explanations: E0282, E0658.\nFor more"} {"sample_index": 10, "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, \"example.com\"));\n println!(\"{}\", Uuid::parse_str(\"a2b7e9b2-2d8c-4f6a-92c6-4e6a6a1d1e11\").unwrap());\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:26\n |\n5 | println!(\"{}\", Uuid::new_v5(Uuid::NAMESPACE_DNS, \"example.com\"));\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::::nil\n uuid::builder::::max\n uuid::builder::::from_fields\n uuid::builder::::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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"} {"sample_index": 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.", "code": "use std::env;\nuse std::fs::File;\nuse std::io::{BufRead, BufReader};\nuse std::path::Path;\n\nfn main() {\n let file = File::open(\"data.txt\").unwrap();\n let reader = BufReader::new(file);\n\n let numbers: Vec = reader\n .lines()\n .filter_map(|x| x.ok())\n .filter_map(|x| x.parse().ok())\n .filter(|&x| x % 2 == 0)\n .map(|x| x * x)\n .collect();\n\n let sum: i32 = numbers.iter().sum();\n\n println!(\"Sum: {}\", sum);\n}", "error_type": "other", "compile_error": "warning: unused import: `std::env`\n --> src/main.rs:1:5\n |\n1 | use std::env;\n | ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nwarning: unused import: `std::path::Path`\n --> src/main.rs:4:5\n |\n4 | use std::path::Path;\n | ^^^^^^^^^^^^^^^\n\nerror[E0284]: type annotations needed\n --> src/main.rs:15:14\n |\n13 | .filter_map(|x| x.parse().ok())\n | ----- type must be known at this point\n14 | .filter(|&x| x % 2 == 0)\n15 | .map(|x| x * x)\n | ^\n |\n = note: cannot satisfy `<_ as FromStr>::Err == _`\nhelp: consider giving this closure parameter an explicit type\n |\n15 | .map(|x: /* Type */| x * x)\n | ++++++++++++\n\nFor more information about this error, try `rustc --explain E0284`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error; 2 warnings emitted\n"} {"sample_index": 13, "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 name: String,\n age: u8,\n address: Address,\n}\n\n#[derive(Serialize, Deserialize)]\nstruct Address {\n street: String,\n city: String,\n state: String,\n}\n\nfn main() {\n let mut p = Person {\n name: \"John\".to_string(),\n age: 30,\n address: Address {\n street: \"123 Main St\".to_string(),\n city: \"Anytown\".to_string(),\n state: \"CA\".to_string(),\n ", "error_type": "trait_error", "compile_error": "error[E0277]: `Person` doesn't implement `Debug`\n --> src/main.rs:32:43\n |\n32 | println!(\"Deserialized Person: {:?}\", new_person);\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"} {"sample_index": 14, "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::{Context, Result};\nuse std::fs::File;\nuse std::io::{self, Read, Write};\nuse std::path::Path;\n\nfn main() -> anyhow::Result<()> {\n let file = File::open(\"foo.txt\")\n .with_context(|| \"Failed to open file 'foo.txt'\")?;\n\n let mut contents = String::new();\n file.read_to_string(&mut contents)\n .with_context(|| \"Failed to read 'foo.txt'\")?;\n\n println!(\"{}\", contents);\n\n let mut file = File::create(\"bar.txt\")\n .with_context(|| \"Failed to create file 'bar.txt'\"", "error_type": "borrow_checker", "compile_error": "warning: unused import: `Result`\n --> src/main.rs:1:23\n |\n1 | use anyhow::{Context, Result};\n | ^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nwarning: unused import: `self`\n --> src/main.rs:3:15\n |\n3 | use std::io::{self, Read, Write};\n | ^^^^\n\nwarning: unused import: `std::path::Path`\n --> src/main.rs:4:5\n |\n4 | use std::path::Path;\n | ^^^^^^^^^^^^^^^\n\nerror[E0596]: cannot borrow `file` as mutable, as it is not declared as mutable\n --> src/main.rs:11:5\n |\n11 | file.read_to_string(&mut contents)\n | ^^^^ cannot borrow as mutable\n |\nhelp: consider changing this to be mutable\n |\n7 | let mut file = File::open(\"foo.txt\")\n | +++\n\nFor more information about this error, try `rustc --explain E0596`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error; 3 warnings emitted\n"} {"sample_index": 16, "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 v = vec!['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];\n let mut count = 0;\n\n println!(\"Random selection of 10 items:\");\n for _ in 0..10 {\n let idx = rng.gen_range(0, v.len());\n let item = v.swap_remove(idx);\n println!(\"{}\", item);\n count += 1;\n }\n\n println!(\"\\nRandom number:\");\n println!(\"{}\", rng.gen_range(0, 100));\n println!(\"\\nRandom float:\");\n println!(\"{}\",", "error_type": "trait_error", "compile_error": "error[E0277]: the trait bound `{integer}: SampleRange<_>` is not satisfied\n --> src/main.rs:10:33\n |\n10 | let idx = rng.gen_range(0, v.len());\n | --------- ^ the trait `SampleRange<_>` is not implemented for `{integer}`\n | |\n | required by a bound introduced by this call\n |\n = help: the following other types implement trait `SampleRange`:\n RangeInclusive\n std::ops::Range\nnote: required by a bound in `gen_range`\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:132:12\n |\n129 | fn gen_range(&mut self, range: R) -> T\n | --------- required by a bound in this associated function\n...\n132 | R: SampleRange\n | ^^^^^^^^^^^^^^ required by this bound in `Rng::gen_range`\n\nerror[E0061]: this method takes 1 argument but 2 arguments were supplied\n --> src/main.rs:10:23\n |\n10 | "} {"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, NaiveDate, NaiveDateTime, Utc};\nuse chrono::format::{FormatItem, FormatResult, StrftimeItems, Timelike};\n\npub struct CustomFormatter {\n pub prefix: String,\n pub suffix: String,\n}\n\nimpl CustomFormatter {\n pub fn new(prefix: String, suffix: String) -> CustomFormatter {\n CustomFormatter { prefix, suffix }\n }\n}\n\nimpl FormatItem for CustomFormatter {\n fn emit(\n &self,\n f: &mut FormatResult,\n value: &str,\n _: &str,\n _: &st", "error_type": "other", "compile_error": "error[E0432]: unresolved imports `chrono::format::FormatItem`, `chrono::format::FormatResult`, `chrono::format::Timelike`\n --> src/main.rs:2:22\n |\n2 | use chrono::format::{FormatItem, FormatResult, StrftimeItems, Timelike};\n | ^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^ no `Timelike` in `format`\n | | |\n | | no `FormatResult` in `format`\n | no `FormatItem` in `format`\n | help: a similar name exists in the module: `format_item`\n |\n = help: consider importing this trait instead:\n chrono::Timelike\n\nwarning: unused import: `DateTime`\n --> src/main.rs:1:14\n |\n1 | use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc};\n | ^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nwarning: unused import: `StrftimeItems`\n --> src/main.rs:2:48\n |\n2 | use chrono::format::{FormatItem, FormatResult, StrftimeItems, Timelike};\n | "} {"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 let uuid1 = Uuid::new_v4();\n let uuid2 = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"rust-lang.org\");\n let uuid3 = Uuid::parse_str(\"a3c2a2d2-2d3a-11e6-86d9-2c7c6bf9a9f9\").unwrap();\n\n println!(\"uuid1: {}\", uuid1);\n println!(\"uuid2: {}\", uuid2);\n println!(\"uuid3: {}\", uuid3);\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:23\n |\n5 | let uuid2 = 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::::nil\n uuid::builder::::max\n uuid::builder::::from_fields\n uuid::builder::::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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"} {"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::iter;\n\nfn main() {\n let numbers: Vec = vec![1, 2, 3, 4, 5];\n let even_numbers: Vec = numbers.iter().filter(|x| x % 2 == 0).cloned().collect();\n\n let sum: i32 = even_numbers.iter().sum();\n\n println!(\"Sum of even numbers is: {}\", sum);\n}", "error_type": "other", "compile_error": "warning: unused import: `std::iter`\n --> src/main.rs:1:5\n |\n1 | use std::iter;\n | ^^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nerror[E0369]: cannot calculate the remainder of `&&i32` divided by `{integer}`\n --> src/main.rs:5:62\n |\n5 | let even_numbers: Vec = numbers.iter().filter(|x| x % 2 == 0).cloned().collect();\n | - ^ - {integer}\n | |\n | &&i32\n |\nhelp: `%` can be used on `&i32` if you dereference the left-hand side\n |\n5 | let even_numbers: Vec = numbers.iter().filter(|x| *x % 2 == 0).cloned().collect();\n | +\n\nFor more information about this error, try `rustc --explain E0369`.\nerror: could not compile `template_app` (bin \"template_app\") due to 1 previous error; 1 warning emitted\n"} {"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, Utc, Local, NaiveDateTime, Datelike, Timelike, TimeZone, SecondsFormat, Utc, FixedOffset, TimeZone};\nuse chrono::format::{self, FormatItem, ParseResult, ParseError, ParseFromStr, ParseFromStrRadix10};\nuse chrono::format::Item::*;\nuse chrono::format::StrftimeItems::*;\nuse chrono::format::StrftimeItems::*;\nuse chrono::format::Weekday::*;\nuse chrono::format::Month::*;\nuse chrono::format::Weekday::*;\nuse chrono::format::Month::*;\nuse chrono::format::YearStyle::*;\nuse chrono::f", "error_type": "other", "compile_error": "error[E0252]: the name `Utc` is defined multiple times\n --> src/main.rs:1:96\n |\n1 | use chrono::{DateTime, Utc, Local, NaiveDateTime, Datelike, Timelike, TimeZone, SecondsFormat, Utc, FixedOffset, TimeZone};\n | --- ^^^--\n | | |\n | | `Utc` reimported here\n | previous import of the type `Utc` here help: remove unnecessary import\n |\n = note: `Utc` must be defined only once in the type namespace of this module\n\nerror[E0252]: the name `TimeZone` is defined multiple times\n --> src/main.rs:1:114\n |\n1 | use chrono::{DateTime, Utc, Local, NaiveDateTime, Datelike, Timelike, TimeZone, SecondsFormat, Utc, FixedOffset, TimeZone};\n | "} {"sample_index": 23, "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 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 name: \"John\".to_string(),\n age: 30,\n address: Address {\n street: \"123 Main St\".to_string(),\n city: \"New York\".to_string(),\n country: \"USA\".to_string()", "error_type": "trait_error", "compile_error": "error[E0277]: `Person` doesn't implement `Debug`\n --> src/main.rs:32:37\n |\n32 | 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"} {"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::{Serialize, Deserialize};\nuse serde_json;\n\n#[derive(Serialize, Deserialize)]\nstruct User {\n id: u32,\n name: String,\n email: String,\n}\n\nfn main() {\n let user = User {\n id: 1,\n name: \"John\".to_string(),\n email: \"john@example.com\".to_string(),\n };\n\n let json = serde_json::to_string(&user).unwrap();\n println!(\"Serialized JSON: {}\", json);\n\n let user2: User = serde_json::from_str(&json).unwrap();\n println!(\"Deserialized JSON: {:?}\", user2);\n}", "error_type": "trait_error", "compile_error": "error[E0277]: `User` doesn't implement `Debug`\n --> src/main.rs:22:41\n |\n22 | println!(\"Deserialized JSON: {:?}\", user2);\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 |\n5 + #[derive(Debug)]\n6 | struct User {\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"} {"sample_index": 27, "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": "// Import necessary libraries\nuse std::env;\nuse std::process;\n\nfn main() {\n // Define an enum to represent the possible values\n enum Animal {\n Cat,\n Dog,\n Bird,\n Unknown,\n }\n\n // Create a vector to store animal names\n let animals = vec![\n Animal::Cat,\n Animal::Dog,\n Animal::Bird,\n Animal::Unknown,\n ];\n\n // Pattern match and print the type of animal\n for animal in animals {\n match animal {\n Animal::C", "error_type": "other", "compile_error": "warning: unused variable: `program_name`\n --> src/main.rs:61:9\n |\n61 | let program_name = env::args().next().unwrap();\n | ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_program_name`\n |\n = note: `#[warn(unused_variables)]` on by default\n\nerror[E0382]: use of moved value: `animals`\n --> src/main.rs:33:19\n |\n15 | let animals = vec![\n | ------- move occurs because `animals` has type `Vec`, which does not implement the `Copy` trait\n...\n23 | for animal in animals {\n | ------- `animals` moved due to this implicit call to `.into_iter()`\n...\n33 | for animal in animals {\n | ^^^^^^^ value used here after move\n |\nnote: `into_iter` takes ownership of the receiver `self`, which moves `animals`\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/collect.rs:346:18\nhelp: consider iterating over a slice of the `Vec`'s content to avoid moving "} {"sample_index": 30, "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(Error, Debug)]\npub enum Error {\n #[error(\"Cannot read file {0}\")]\n IoError(#[from] std::io::Error),\n #[error(\"Cannot parse string: {0}\")]\n ParseError(String),\n}\n\nfn main() -> Result<(), Error> {\n let f = std::fs::File::open(\"non-existent-file\")?;\n let s = std::str::from_utf8(&f.read_to_string(&mut std::io::sink()?)?);\n let _: u8 = s?.parse()?;\n Ok(())\n}", "error_type": "type_mismatch", "compile_error": "error[E0599]: no method named `read_to_string` found for struct `File` in the current scope\n --> src/main.rs:13:36\n |\n13 | let s = std::str::from_utf8(&f.read_to_string(&mut std::io::sink()?)?);\n | ^^^^^^^^^^^^^^\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/io/mod.rs:904:8\n |\n = note: the method is available for `File` here\n |\n = help: items from traits can only be used if the trait is in scope\nhelp: trait `Read` which provides `read_to_string` is implemented but not in scope; perhaps you want to import it\n |\n1 + use std::io::Read;\n |\nhelp: there is a method `read_to_end` with a similar name\n |\n13 | let s = std::str::from_utf8(&f.read_to_end(&mut std::io::sink()?)?);\n | ~~~~~~~~~~~\n\nerror[E0277]: the `?` operator can only be applied to values that implement `Try`\n --> src/main.rs:13:56\n |\n13 | let s = std::str::from_utf8(&f.read_to_string(&mut std::io::sin"} {"sample_index": 31, "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 uuid1 = Uuid::new_v4();\n let uuid2 = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"example.com\");\n let uuid3 = Uuid::new_v5(Uuid::NAMESPACE_URL, \"https://example.com\");\n let uuid4 = Uuid::new_v5(Uuid::NAMESPACE_OID, \"1.2.3\");\n let uuid5 = Uuid::new_v5(Uuid::NAMESPACE_URL, \"https://example.com\");\n\n println!(\"{:?}\", uuid1);\n println!(\"{:?}\", uuid2);\n println!(\"{:?}\", uuid3);\n println!(\"{:?}\", uuid4);\n println!(\"{:?}\", uuid5);\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:23\n |\n5 | let uuid2 = Uuid::new_v5(Uuid::NAMESPACE_DNS, \"example.com\");\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::::nil\n uuid::builder::::max\n uuid::builder::::from_fields\n uuid::builder::::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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"} {"sample_index": 33, "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: i32,\n}\n\nfn main() {\n let person = Person {\n first_name: \"John\".to_string(),\n last_name: \"Doe\".to_string(),\n age: 25,\n };\n\n let json = serde_json::to_string(&person).unwrap();\n\n println!(\"{}\", json);\n\n let deserialized_person: Person = serde_json::from_str(&json).unwrap();\n\n println!(\"{:#?}\", deserialized_person);\n}", "error_type": "trait_error", "compile_error": "error[E0277]: `Person` doesn't implement `Debug`\n --> src/main.rs:23:23\n |\n23 | println!(\"{:#?}\", deserialized_person);\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)\nhelp: consider annotating `Person` with `#[derive(Debug)]`\n |\n4 + #[derive(Debug)]\n5 | struct Person {\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"} {"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 random_number: u32 = rand::thread_rng().gen_range(0, 10);\n\n let random_number_list: Vec = 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 ];\n\n let random_string: String = rando", "error_type": "trait_error", "compile_error": "error[E0277]: the trait bound `{integer}: SampleRange<_>` is not satisfied\n --> src/main.rs:4:59\n |\n4 | let random_number: u32 = rand::thread_rng().gen_range(0, 10);\n | --------- ^ the trait `SampleRange<_>` is not implemented for `{integer}`\n | |\n | required by a bound introduced by this call\n |\n = help: the following other types implement trait `SampleRange`:\n RangeInclusive\n std::ops::Range\nnote: required by a bound in `gen_range`\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:132:12\n |\n129 | fn gen_range(&mut self, range: R) -> T\n | --------- required by a bound in this associated function\n...\n132 | R: SampleRange\n | ^^^^^^^^^^^^^^ required by this bound in `Rng::gen_range`\n\nerror[E0061]: "} {"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::prelude::*;\n\nfn main() {\n let date_str = \"2022-01-01T12:30:30Z\";\n let date = DateTime::parse_from_rfc3339(date_str).unwrap();\n println!(\"Date: {}\", date.format(\"%Y-%m-%d\").to_string());\n println!(\"Time: {}\", date.format(\"%H:%M:%S\").to_string());\n println!(\"UTC Offset: {}\", date.offset().offset().num_minutes());\n println!(\"ISO 8601: {}\", date.format(\"%Y-%m-%dT%H:%M:%SZ\").to_string());\n println!(\"Weekday: {}\", date.weekday());\n println!(\"Day of week: {}\", date.w", "error_type": "other", "compile_error": "error[E0599]: no method named `offset` found for reference `&FixedOffset` in the current scope\n --> src/main.rs:8:46\n |\n8 | println!(\"UTC Offset: {}\", date.offset().offset().num_minutes());\n | ---- ^^^^^^ method not found in `&FixedOffset`\n | |\n | method `offset` is available on `&chrono::DateTime`\n\nerror[E0599]: no method named `name` found for enum `Weekday` in the current scope\n --> src/main.rs:11:48\n |\n11 | println!(\"Day of week: {}\", date.weekday().name());\n | ^^^^\n |\nhelp: there is a method `ne` with a similar name, but with different arguments\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/cmp.rs:261:5\n\nerror[E0599]: no method named `num_weeks_from_start` found for enum `Weekday` in the current scope\n --> src/main.rs:18:52\n |\n18 | println!(\"Weekday of year: {}\", date.wee"} {"sample_index": 39, "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: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n let b: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n let c: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n let d: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n\n let x = 1;\n let y = 2;\n\n let z = x + y;\n let w = b + c;\n let q = a + d;\n\n if z == w || z == q {\n O", "error_type": "undefined_variable", "compile_error": "error: cannot find macro `anyhow` in this scope\n --> src/main.rs:4:53\n |\n4 | let a: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n | ^^^^^^\n |\n = note: `anyhow` is in scope, but it is a crate, not a macro\nhelp: consider importing this macro\n |\n1 + use anyhow::anyhow;\n |\n\nerror: cannot find macro `anyhow` in this scope\n --> src/main.rs:5:53\n |\n5 | let b: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n | ^^^^^^\n |\n = note: `anyhow` is in scope, but it is a crate, not a macro\nhelp: consider importing this macro\n |\n1 + use anyhow::anyhow;\n |\n\nerror: cannot find macro `anyhow` in this scope\n --> src/main.rs:6:53\n |\n6 | let c: i32 = \"not an i32\".parse().map_err(|err| anyhow!(\"could not parse\"))?;\n | ^^^^^^\n |\n = note: `anyhow` is in scope, but it is a crate, not "} {"sample_index": 41, "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(\"This is a custom error with a cause\")]\n Custom { source: Box },\n #[error(\"This is a custom error without a cause\")]\n NoCause,\n #[error(\"This is a custom error with a message\")]\n CustomMessage(String),\n}\n\nfn foo() -> Result<(), MyError> {\n Err(MyError::Custom {\n source: Box::new(42),\n })?;\n Ok(())\n}\n\nfn main() {\n let r = foo();\n match r {\n ", "error_type": "other", "compile_error": "error[E0599]: the method `as_dyn_error` exists for reference `&Box`, but its trait bounds were not satisfied\n --> src/main.rs:7:14\n |\n7 | Custom { source: Box },\n | ^^^^^^ method cannot be called on `&Box` due to unsatisfied trait bounds\n |\n = note: the following trait bounds were not satisfied:\n `Box: std::error::Error`\n which is required by `Box: AsDynError<'_>`\n `&Box: std::error::Error`\n which is required by `&Box: AsDynError<'_>`\n `dyn Debug: Sized`\n which is required by `dyn Debug: AsDynError<'_>`\n `dyn Debug: std::error::Error`\n which is required by `dyn Debug: AsDynError<'_>`\n\nerror[E0369]: binary operation `==` cannot be applied to type `&Box`\n --> src/main.rs:7:14\n |\n4 | #[derive(Debug, Error, PartialEq)]\n | --------- in this derive macro expansion\n...\n7 | Custom {"} {"sample_index": 42, "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];\n\n let even_numbers = numbers.iter().filter(|&x| x % 2 == 0);\n let sum = even_numbers.map(|x| x * x).sum();\n\n println!(\"{}\", sum);\n}", "error_type": "other", "compile_error": "error[E0283]: type annotations needed\n --> src/main.rs:5:9\n |\n5 | let sum = even_numbers.map(|x| x * x).sum();\n | ^^^ --- type must be known at this point\n |\n = note: cannot satisfy `_: Sum`\n = help: the following types implement trait `Sum`:\n `Duration` implements `Sum<&'a Duration>`\n `Duration` implements `Sum`\n `Option` implements `Sum>`\n `Result` implements `Sum>`\n `Simd` implements `Sum<&'a Simd>`\n `Simd` implements `Sum`\n `Simd` implements `Sum<&'a Simd>`\n `Simd` implements `Sum`\n and 72 others\nnote: required by a bound in `std::iter::Iterator::sum`\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/iterator.rs:3572:5\nhelp: consider giving `sum` an explicit type\n |\n5 | let sum: /* Type */ = even_numbers.map(|x| x * x"} {"sample_index": 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.", "code": "use serde::{Serialize, Deserialize};\nuse serde_json;\n\n#[derive(Serialize, Deserialize)]\nstruct User {\n name: String,\n age: u8,\n email: String,\n address: Address,\n}\n\n#[derive(Serialize, Deserialize)]\nstruct Address {\n street: String,\n city: String,\n state: String,\n zip: String,\n}\n\nfn main() {\n let user = User {\n name: \"John\".to_string(),\n age: 32,\n email: \"john@example.com\".to_string(),\n address: Address {\n street: \"123 Main St\".to", "error_type": "trait_error", "compile_error": "error[E0277]: `User` doesn't implement `Debug`\n --> src/main.rs:37:22\n |\n37 | println!(\"{:?}\", user_from_json);\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)\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"} {"sample_index": 44, "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::io;\n\n#[derive(Debug, Error, Display)]\npub enum MyError {\n #[error(\"I/O error: {0}\")]\n Io(#[from] io::Error),\n #[error(\"Something went wrong: {0}\")]\n Something(#[from] Box),\n}\n\n#[tokio::main]\nasync fn main() -> Result<(), MyError> {\n let result = std::fs::read_to_string(\"non-existent-file.txt\")?;\n println!(\"File contents: {}\", result);\n\n Ok(())\n}", "error_type": "undefined_variable", "compile_error": "error[E0433]: failed to resolve: use of undeclared crate or module `tokio`\n --> src/main.rs:12:3\n |\n12 | #[tokio::main]\n | ^^^^^ use of undeclared crate or module `tokio`\n\nerror: cannot find derive macro `Display` in this scope\n --> src/main.rs:4:24\n |\n4 | #[derive(Debug, Error, Display)]\n | ^^^^^^^\n\nerror[E0752]: `main` function is not allowed to be `async`\n --> src/main.rs:13:1\n |\n13 | async fn main() -> Result<(), MyError> {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` function is not allowed to be `async`\n\nSome errors have detailed explanations: E0433, E0752.\nFor more information about an error, try `rustc --explain E0433`.\nerror: could not compile `template_app` (bin \"template_app\") due to 3 previous errors\n"} {"sample_index": 45, "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;\nuse rand::distributions::Alphanumeric;\nuse rand::prelude::*;\n\nfn main() {\n let mut rng = thread_rng();\n\n let mut random_alphanumeric = String::new();\n let mut random_int = 0;\n\n let mut v = vec![\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\"];\n\n for _ in 0..10 {\n random_alphanumeric = String::from_utf8(vec![rng.sample(Alphanumeric)].into_iter().collect())\n .unwrap()\n .to_string();\n\n random_int = rng.gen_range(0, v.len());\n ", "error_type": "trait_error", "compile_error": "error[E0277]: the trait bound `{integer}: SampleRange<_>` is not satisfied\n --> src/main.rs:18:36\n |\n18 | random_int = rng.gen_range(0, v.len());\n | --------- ^ the trait `SampleRange<_>` is not implemented for `{integer}`\n | |\n | required by a bound introduced by this call\n |\n = help: the following other types implement trait `SampleRange`:\n RangeInclusive\n std::ops::Range\nnote: required by a bound in `gen_range`\n --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:132:12\n |\n129 | fn gen_range(&mut self, range: R) -> T\n | --------- required by a bound in this associated function\n...\n132 | R: SampleRange\n | ^^^^^^^^^^^^^^ required by this bound in `Rng::gen_range`\n\nerror[E0061]: this method takes 1 argument but 2 arguments were supplied\n --> src/main.rs:18:26\n "} {"sample_index": 49, "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::env;\nuse std::process;\n\nfn main() {\n let args: Vec = env::args().collect();\n let args: Vec = args.iter()\n .skip(1)\n .map(|arg| arg.parse().unwrap_or_else(|_| panic!(\"Invalid argument\")))\n .collect();\n\n let sum = args.iter().filter(|&&x| x > 0).sum::();\n\n match sum {\n Some(s) => println!(\"{}\", s),\n None => println!(\"Sum is 0\"),\n }\n}", "error_type": "type_mismatch", "compile_error": "warning: unused import: `std::process`\n --> src/main.rs:2:5\n |\n2 | use std::process;\n | ^^^^^^^^^^^^\n |\n = note: `#[warn(unused_imports)]` on by default\n\nerror[E0308]: mismatched types\n --> src/main.rs:14:9\n |\n13 | match sum {\n | --- this expression has type `i32`\n14 | Some(s) => println!(\"{}\", s),\n | ^^^^^^^ expected `i32`, found `Option<_>`\n |\n = note: expected type `i32`\n found enum `Option<_>`\n\nerror[E0308]: mismatched types\n --> src/main.rs:15:9\n |\n13 | match sum {\n | --- this expression has type `i32`\n14 | Some(s) => println!(\"{}\", s),\n15 | None => println!(\"Sum is 0\"),\n | ^^^^ expected `i32`, found `Option<_>`\n |\n = note: expected type `i32`\n found enum `Option<_>`\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"} {"sample_index": 51, "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(\"error 1\")]\n Error1,\n #[error(\"error 2\")]\n Error2(#[source] Box),\n #[error(\"error 3\")]\n Error3(String),\n}\n\nfn divide(a: i32, b: i32) -> Result {\n if b == 0 {\n return Err(MyError::Error1);\n }\n Ok(a / b)\n}\n\nfn main() {\n match divide(5, 2) {\n Ok(x) => println!(\"Result is: {}\", x),\n Err(e) => println!(\"Error: {}\", e),\n }\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[E0404]: expected trait, found derive macro `Error`\n --> src/main.rs:8:30\n |\n8 | Error2(#[source] Box),\n | ^^^^^ not a trait\n |\nhelp: consider importing one of these traits instead\n |\n1 + use std::error::Error;\n |\n1 + use serde::de::Error;\n |\n1 + use serde::ser::Error;\n |\n\nFor more information about this error, try `rustc --explain E0404`.\nerror: could not compile `template_app` (bin \"template_app\") due to 2 previous errors\n"} {"sample_index": 52, "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::{Serialize, Deserialize};\n\n#[derive(Serialize, Deserialize)]\nstruct Person {\n first_name: String,\n last_name: String,\n age: u8,\n}\n\nfn main() {\n let person = Person {\n first_name: \"John\".to_string(),\n last_name: \"Doe\".to_string(),\n age: 30,\n };\n\n let serialized = serde_json::to_string(&person).unwrap();\n println!(\"Serialized: {}\", serialized);\n\n let deserialized: Person = serde_json::from_str(&serialized).unwrap();\n println!(\"Deserialized", "error_type": "trait_error", "compile_error": "error[E0277]: `Person` doesn't implement `Debug`\n --> src/main.rs:21:36\n |\n21 | 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)\nhelp: consider annotating `Person` with `#[derive(Debug)]`\n |\n4 + #[derive(Debug)]\n5 | struct Person {\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"} {"sample_index": 53, "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\nstruct U32Bytes([u8; 32]);\n\nimpl FromStr for U32Bytes {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let mut bytes = [0u8; 32];\n let len = s.len();\n if len > 32 {\n return Err(std::num::ParseIntError);\n }\n for (i, c) in s.bytes().enumerate() {\n if c < b'0' || c > b'9' {\n return Err(std::num::ParseIntError);\n }\n bytes[i] = c - b'0';\n ", "error_type": "undefined_variable", "compile_error": "error[E0405]: cannot find trait `FromStr` in this scope\n --> src/main.rs:5:6\n |\n5 | impl FromStr for U32Bytes {\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:11:24\n |\n11 | return Err(std::num::ParseIntError);\n | ^^^^^^^^^^^^^^^^^^^^^^^\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/num/error.rs:66:1\n |\n = note: `std::num::ParseIntError` defined here\n\nerror[E0423]: expected value, found struct `std::num::ParseIntError`\n --> src/main.rs:15:28\n |\n15 | return Err(std::num::ParseIntError);\n | ^^^^^^^^^^^^^^^^^^^^^^^\n --> /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/num/error.rs:66:1\n |\n = note: `std::num::ParseIntError` defined here\n\nSome errors have detailed explanations: E0405, E0423.\nFor more i"}