conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add simple select usage without a struct\n" }, { "from": "gpt", "value": "#[macro_use]\nextern crate rustorm_codegen;\nextern crate rustorm_dao as dao;\nextern crate rustorm_dao;\nextern crate rustorm;\nuse rustorm::TableName;\nuse rustorm_dao::ToColumnNames;\nuse ru...
rust
chosen
[ { "from": "human", "value": "Add rust code for grade-school\n\nIt passed all testcases. It is better to use a sorted link list.\n" }, { "from": "gpt", "value": "const MAX_GRADES: usize = 9;\n\n#[derive(Default)]\npub struct School {\n db: Vec<Vec<String>>,\n}\n\nimpl School {\n pub fn new(...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 24\n" }, { "from": "gpt", "value": "#![feature(collections)]\n#[macro_use] extern crate libeuler;\n\nuse std::collections::HashMap;\nuse std::slice::SliceConcatExt;\n\n/// A permutation is an ordered arrangement of objects. For example, 3124 i...
rust
chosen
[ { "from": "human", "value": "Add rust code for phone-number case\n\nI will clean up code later. Currently it works.\n" }, { "from": "gpt", "value": "#![feature(ascii_ctype)]\nuse std::ascii::AsciiExt;\n\n\nfn check_countrycode(mut phone: Vec<u8>) -> Option<String> {\n println!(\"{:?}\", phone...
rust
chosen
[ { "from": "human", "value": "Implement a data Reader utility\n" }, { "from": "gpt", "value": "use std::str;\nuse object_id;\nuse object_id::ObjectId;\n\npub struct Reader<'a> {\n position: uint,\n data: &'a [u8]\n}\n\nimpl<'a> Reader<'a> {\n pub fn from_data(bytes: &'a[u8]) -> Reader<'a...
rust
chosen
[ { "from": "human", "value": "Test use of impl Trait in an impl as the value for an associated type in an impl trait\n" }, { "from": "gpt", "value": "// check-pass\n\n#![feature(type_alias_impl_trait)]\n#![allow(dead_code)]\n\ntype Foo = impl Iterator<Item = impl Send>;\n\nfn make_foo() -> Foo {\...
rust
chosen
[ { "from": "human", "value": "Add rust code for nth-prime\n\nIt passed all testcases\n" }, { "from": "gpt", "value": "pub fn nth(index: u32) -> Result<u32, String> {\n if index == 0 {\n return Err(\"Invalid index\".to_string());\n }\n\n let mut number = 3;\n let mut primes = Ve...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 28\n" }, { "from": "gpt", "value": "#[macro_use] extern crate libeuler;\n\n/// Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is\n/// formed as follows:\n///\n/// 21 22 ...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 44\n" }, { "from": "gpt", "value": "#[macro_use] extern crate libeuler;\n\n/// Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers\n/// are:\n///\n/// 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ...\n///...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 53\n" }, { "from": "gpt", "value": "#![feature(core)]\n#[macro_use] extern crate libeuler;\n\nuse std::collections::HashMap;\nuse std::iter::range_inclusive;\n/// There are exactly ten ways of selecting three from five, 12345:\n///\n/// 123, 1...
rust
chosen
[ { "from": "human", "value": "Test CU directory is the work_dir\n\nMake sure that we don't regress setting of the CU directory to the\nworking directory.\n" }, { "from": "gpt", "value": "// compile-flags: -g --remap-path-prefix={{cwd}}=/cwd/ --remap-path-prefix={{src-base}}=/base/\n// ignore-tidy...
rust
chosen
[ { "from": "human", "value": "Read all header from a Fits file\n" }, { "from": "gpt", "value": "extern crate nom;\nextern crate fits_rs;\n\nuse std::env;\nuse std::fs::File;\nuse std::io::Read;\nuse std::str::FromStr;\nuse nom::IResult;\nuse fits_rs::parser::fits;\nuse fits_rs::types::Header;\n\n...
rust
chosen
[ { "from": "human", "value": "Add test of impl formatting\n" }, { "from": "gpt", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache License...
rust
chosen
[ { "from": "human", "value": "Add rust code for luhn\n\nIt is ugly but works\n" }, { "from": "gpt", "value": "pub fn is_valid(id: &str) -> bool {\n // check the length\n if id.len() < 2 {\n return false;\n }\n\n let mut index: u32 = 0;\n let mut number: Vec<u32> = Vec::new()...
rust
chosen
[ { "from": "human", "value": "Add macros to simplify reading from stdin in Rust\n" }, { "from": "gpt", "value": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var,...
rust
chosen
[ { "from": "system", "value": "Fix a pprint test for fixed-length vecs\n" }, { "from": "human", "value": "// pp-exact\nfn f() -> [int]/3 {\n let picard = 0;\n\n let data = 1;\n\n let worf = 2;\n\n\n let enterprise = [picard, data, worf]/_;\n\n\n\n return enterprise;\n}\n" }, { ...
rust
chosen
[ { "from": "human", "value": "Add test of Display and Debug impls\n" }, { "from": "gpt", "value": "use anyhow::{bail, Context, Result};\n\nfn f() -> Result<()> {\n bail!(\"oh no!\");\n}\n\nfn g() -> Result<()> {\n f().context(\"f failed\")\n}\n\nfn h() -> Result<()> {\n g().context(\"g f...
rust
chosen
[ { "from": "human", "value": "Add test for source files feature\n" }, { "from": "gpt", "value": "// Copyright 2018 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache L...
rust
chosen
[ { "from": "human", "value": "Add a point counting example\n" }, { "from": "gpt", "value": "//! Count the number of points in the file twice, once with sync-to-pps and once without.\n\nextern crate scanifc;\n\nuse scanifc::point3d::Stream;\n\nfn main() {\n let ref path = std::env::args().skip(...
rust
chosen
[ { "from": "human", "value": "Add test of anyhow macro tagged dispatch\n" }, { "from": "gpt", "value": "use anyhow::anyhow;\nuse std::error::Error as StdError;\nuse std::fmt::{self, Display};\nuse std::io;\n\n#[derive(Debug)]\nenum TestError {\n Io(io::Error),\n}\n\nimpl Display for TestError ...
rust
chosen
[ { "from": "human", "value": "Create a algebraic datatype code sample\n" }, { "from": "gpt", "value": "enum Tree {\n Empty,\n Leaf(i32),\n Node(Box<Tree>, Box<Tree>)\n}\n\nimpl std::fmt::Display for Tree {\n fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n mat...
rust
chosen
[ { "from": "human", "value": "Add a test demonstrating the limitations of our lfietime resolution\n" }, { "from": "gpt", "value": "trait Id {\n type Out;\n\n fn id(self) -> Self::Out;\n}\n\nimpl<'a> Id for &'a mut i32 {\n type Out = &'a mut i32;\n\n fn id(self) -> Self { self }\n}\n\n...
rust
chosen
[ { "from": "human", "value": "Add test case for omitting dllimport during cross-lang LTO.\n" }, { "from": "gpt", "value": "// Copyright 2018 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// L...
rust
chosen
[ { "from": "human", "value": "Add test case for Self:: links\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n// @has foo/enum.E1.html '//a/@href' '../foo/enum.E1.html#variant.A'\n\n/// [Self::A::b]\npub enum E1 {\n A { b: usize }\n}\n\n// @has foo/enum.E2.html '//a/@href' '../foo/en...
rust
chosen
[ { "from": "human", "value": "Add rust code for clock case\n\nIt passed all testcases\n" }, { "from": "gpt", "value": "#[derive(Debug, PartialEq)]\npub struct Clock {\n hour: i32,\n minute: i32,\n}\n\nimpl Clock {\n #[inline]\n fn normalize(hour: i32, minute: i32) -> (i32, i32) {\n ...
rust
chosen
[ { "from": "human", "value": "Add failing test for rosmsg derives\n" }, { "from": "gpt", "value": "// Long arrays as message fields cause a structure to be unable to automatically derive.\n//\n// Compilation of this test makes sure this is handled for those cases.\n\nmod msg {\n rosrust::rosms...
rust
chosen
[ { "from": "human", "value": "Test case for new `derive(PartialOrd)` expansion.\n" }, { "from": "gpt", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed un...
rust
chosen
[ { "from": "human", "value": "Add rust code for rna-transcription\n\nIt passes all tests\n" }, { "from": "gpt", "value": "#[derive(Debug, PartialEq)]\npub struct RibonucleicAcid(String);\n\nimpl RibonucleicAcid {\n pub fn new(serial: &str) -> RibonucleicAcid {\n RibonucleicAcid(serial.t...
rust
chosen
[ { "from": "human", "value": "Test that all structs are actually empty\n" }, { "from": "gpt", "value": "extern crate llvm_safe;\n\nuse std::mem;\n\nuse llvm_safe::llvm::{BasicBlock, Label, Builder, PositionedBuilder, Constant, Context, Function, FunctionLabel, Module, Phi, Target, TargetMachine, ...
rust
chosen
[ { "from": "human", "value": "Add weird return types TAIT test\n" }, { "from": "gpt", "value": "// edition:2018\n// check-pass\n\n#![feature(type_alias_impl_trait)]\n#![allow(dead_code)]\n\nuse std::future::Future;\nuse std::fmt::Debug;\n\ntype Foo = impl Debug;\n\nfn f() -> impl Future<Output = ...
rust
chosen
[ { "from": "human", "value": "Add example for parse and eval R code from string\n" }, { "from": "gpt", "value": "extern crate libc;\nextern crate libr;\nuse std::ptr;\nuse std::env;\nuse std::ffi::{CStr, CString};\n\nuse libr::ffi::internals::*;\nuse libr::ffi::embedded::{self, Rf_endEmbeddedR, R...
rust
chosen
[ { "from": "human", "value": "Add a super simple example with a moving rectangle\n" }, { "from": "gpt", "value": "extern crate ggez;\nuse ggez::conf;\nuse ggez::event;\nuse ggez::{GameResult, Context};\nuse ggez::graphics;\nuse ggez::graphics::{Color, DrawMode, Point};\nuse std::time::Duration;\n...
rust
chosen
[ { "from": "human", "value": "Add meh solution for problem 19\n" }, { "from": "gpt", "value": "#[macro_use] extern crate libeuler;\n\n\n\n// You are given the following information, but you may prefer to do some research for yourself.\n//\n// 1 Jan 1900 was a Monday.\n//\n// Thirty days has Sep...
rust
chosen
[ { "from": "human", "value": "Move along; nothing to see here...\n" }, { "from": "gpt", "value": "fn main() {\n\n // The Internet made me do it.\n\n obj cat() {\n fn ack() -> str {\n ret \"ack\";\n }\n fn meow() -> str {\n ret \"meow\";\n }\...
rust
chosen
[ { "from": "human", "value": "Add an idealistic test for optimize attribute\n\nAlas it does not currently work, because of limitations in compiletest…\n" }, { "from": "gpt", "value": "// revisions: NO-OPT SIZE-OPT SPEED-OPT\n// [NO-OPT]compile-flags: -Copt-level=0\n// [SIZE-OPT]compile-flags: -Co...
rust
chosen
[ { "from": "human", "value": "Add regression test for ICE in constant blocks\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under...
rust
chosen
[ { "from": "human", "value": "Add a test for unique boxes containing shared boxes\n\nIssue #409\n" }, { "from": "gpt", "value": "use std;\nimport std::sys::rustrt::refcount;\n\nfn main() {\n let i = ~@1;\n let j = ~@2;\n let rc1 = refcount(*i);\n let j = i;\n let rc2 = refcount(*i)...
rust
chosen
[ { "from": "human", "value": "Add a really basic example\n" }, { "from": "gpt", "value": "extern mod glfw;\nextern mod gl;\n\n#[start]\nfn start(argc: int, argv: **u8, crate_map: *u8) -> int {\n // Run GLFW on the main thread\n std::rt::start_on_main_thread(argc, argv, crate_map, main)\n}\n...
rust
chosen
[ { "from": "human", "value": "Add test for eval order for a+=b\n\nYes, the order of evaluation *does* change depending on the types of\nthe operands. Cursed, I know.\n\nI've elected to place this test into `expr/compound-assignment` creating\nboth the `expr` directory and the `compound-assignment` directory....
rust
chosen
[ { "from": "human", "value": "Add a binary for the example\n\nThis makes `cargo run --example rust-issue-30123` run an example!\n" }, { "from": "gpt", "value": "extern crate multirust;\nextern crate rust_bisect;\nextern crate rust_install;\n\nuse std::env;\nuse std::ffi::OsStr;\nuse std::path::Pa...
rust
chosen
[ { "from": "human", "value": "Add a test case for calling generic functions taking alias args with box types\n" }, { "from": "gpt", "value": "// xfail-boot\n// xfail-stage0\n\nfn id[T](&T t) -> T {\n ret t;\n}\n\nfn main() {\n auto expected = @100;\n auto actual = id[@int](expected);\n log *a...
rust
chosen
[ { "from": "human", "value": "Add test for {impl,declare}_lint_pass macros\n" }, { "from": "gpt", "value": "// compile-flags: -Z unstable-options\n// check-pass\n\n#![feature(rustc_private)]\n\nextern crate rustc_session;\n\nuse rustc_session::lint::{LintArray, LintPass};\nuse rustc_session::{dec...
rust
chosen
[ { "from": "human", "value": "Add bench server example with settings usage.\n" }, { "from": "gpt", "value": "\n/// WebSocket server used for testing the bench example.\nextern crate ws;\n\nuse ws::{Builder, Settings, Sender};\n\nfn main () {\n Builder::new().with_settings(Settings {\n m...
rust
chosen
[ { "from": "human", "value": "Add a benchmark test for buffer tokens\n" }, { "from": "gpt", "value": "#![feature(test)]\n\nextern crate test;\nextern crate scribe;\n\nuse test::Bencher;\nuse scribe::Workspace;\nuse std::path::PathBuf;\n\n#[bench]\nfn bench_tokens(b: &mut Bencher) {\n // Create...
rust
chosen
[ { "from": "human", "value": "Test that `core::assert!` is valid\n" }, { "from": "gpt", "value": "// compile-flags: --crate-type=lib\n// check-pass\n// issue #55482\n#![no_std]\n\nmacro_rules! foo {\n ($e:expr) => {\n $crate::core::assert!($e);\n $crate::core::assert_eq!($e, true...
rust
chosen
[ { "from": "system", "value": "Add &self to Liquid method\n" }, { "from": "human", "value": "#![feature(phase)]\n#[phase(plugin)]\nextern crate regex_macros;\nextern crate regex;\n\nuse std::collections::HashMap;\n\nmod lexer;\nmod parser;\n\nstruct Liquid {\n text: String,\n content: HashM...
rust
chosen
[ { "from": "human", "value": "Add test of common PartialEq cases\n" }, { "from": "gpt", "value": "use serde_bytes::{Bytes, ByteBuf};\n\nfn _bytes_eq_slice(bytes: &Bytes, slice: &[u8]) -> bool {\n bytes == slice\n}\n\nfn _bytebuf_eq_vec(bytebuf: ByteBuf, vec: Vec<u8>) -> bool {\n bytebuf == ...
rust
chosen
[ { "from": "human", "value": "Add unit tests for new lint\n" }, { "from": "gpt", "value": "#![warn(clippy::for_loops_over_options)]\n\nfn main() {\n let x = vec![Some(1), Some(2), Some(3)];\n for n in x {\n if let Some(n) = n {\n println!(\"{}\", n);\n }\n }\n\n ...
rust
chosen
[ { "from": "human", "value": "Add a run-pass-valgrind test for vecdeque issue\n" }, { "from": "gpt", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed unde...
rust
chosen
[ { "from": "human", "value": "Add a frame data example\n" }, { "from": "gpt", "value": "use std::env;\n\nuse getopts::Options;\nuse pdb::FallibleIterator;\n\nfn print_usage(program: &str, opts: Options) {\n let brief = format!(\"Usage: {} input.pdb\", program);\n print!(\"{}\", opts.usage(&...
rust
chosen
[ { "from": "system", "value": "Upgrade to rust-url with renamed crate.\n" }, { "from": "human", "value": "#![crate_name = \"http\"]\n\n#![comment = \"Rust HTTP server\"]\n#![license = \"MIT/ASL2\"]\n#![crate_type = \"dylib\"]\n#![crate_type = \"rlib\"]\n\n#![doc(html_root_url = \"http://www.rust-...
rust
chosen
[ { "from": "human", "value": "Add Entry type for store\n" }, { "from": "gpt", "value": "use std::path::PathBuf;\n\nuse header::EntryHeader;\nuse content::EntryContent;\n\npub struct Entry {\n location: PathBuf,\n header: EntryHeader,\n content: EntryContent,\n}\n\n" } ]
rust
chosen
[ { "from": "human", "value": "Add ui test of handwritten Drop for shared struct\n" }, { "from": "gpt", "value": "#[cxx::bridge]\nmod ffi {\n struct Shared {\n fd: i32,\n }\n}\n\nimpl Drop for ffi::Shared {\n fn drop(&mut self) {\n println!(\"close({})\", self.fd);\n }\n}...
rust
chosen
[ { "from": "system", "value": "test: Use a mod that exists in view-item-at-top\n" }, { "from": "human", "value": "use std;\n\nfn f() {\n}\n\nimport std::io::println; //~ ERROR view items must be declared at the top\n\nfn main() {\n}\n\n" }, { "from": "gpt", "value": "use std;\n\nfn...
rust
chosen
[ { "from": "human", "value": "Add test for missing stability checker\n" }, { "from": "gpt", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apa...
rust
chosen
[ { "from": "human", "value": "Print an error message if neither Canvas 2D backend is selected\n" }, { "from": "gpt", "value": "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain on...
rust
chosen
[ { "from": "human", "value": "Add missing file to last commit\n" }, { "from": "gpt", "value": "use std::fmt;\n\n\n#[derive(Debug, Eq, PartialEq)]\npub enum Error {\n /// Could not connect\n ConnectionError,\n /// Invalid modbus slave id.\n InvalidSlaveID,\n InvalidRTUSerialMode,\n ...
rust
chosen
[ { "from": "human", "value": "Add an example to read password\n" }, { "from": "gpt", "value": "use std::borrow::Cow::{self, Borrowed, Owned};\n\nuse rustyline::completion::Completer;\nuse rustyline::config::Configurer;\nuse rustyline::highlight::Highlighter;\nuse rustyline::hint::Hinter;\nuse rus...
rust
chosen
[ { "from": "human", "value": "Add new minimal test for current blocker on bootstrapping.\n" }, { "from": "gpt", "value": "// xfail-stage0\n\ntag colour { red; green; }\n\nobj foo[T]() {\n fn meth(&T x) {\n }\n}\n\nfn main() {\n foo[colour]().meth(red);\n}" } ]
rust
chosen
[ { "from": "human", "value": "Add test for sidebar link generation\n" }, { "from": "gpt", "value": "// Copyright 2014 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apach...
rust
chosen
[ { "from": "human", "value": "Add test for unknown attribute lint\n" }, { "from": "gpt", "value": "// Copyright 2013 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache...
rust
chosen
[ { "from": "human", "value": "test: Add a compile-fail test for attribute/syntax parsing\n\nI don't currently know how to deal with syntax extensions that appear betweeen\nan attribute and an item, so this test captures the error that occurs.\n\nIssue #487\n" }, { "from": "gpt", "value": "// xfai...
rust
chosen
[ { "from": "human", "value": "Test ASCII ctype methods in a const context\n" }, { "from": "gpt", "value": "// run-pass\n\n#![feature(const_ascii_ctype_on_intrinsics)]\n\nmacro_rules! suite {\n ( $( $fn:ident => [$a:ident, $A:ident, $nine:ident, $dot:ident, $space:ident]; )* ) => {\n $(\...
rust
chosen
[ { "from": "human", "value": "Move inner deflate function as well\n" }, { "from": "gpt", "value": "use std::mem;\nuse crate::{MZResult, MZFlush, MZError, MZStatus};\nuse crate::deflate::core::{TDEFLStatus, TDEFLFlush, CompressorOxide, compress};\n\npub fn deflate(compressor: &mut CompressorOxide,...
rust
chosen
[ { "from": "human", "value": "Add a test that tests typestate checking inside of fn exprs.\n" }, { "from": "gpt", "value": "// error-pattern:Unsatisfied precondition\n// xfail-stage0\n\nfn main() {\n // Typestate should work even in a lambda. we should reject this program.\n auto f = fn () ...
rust
chosen
[ { "from": "system", "value": "test: Fix botched error message in compile-fail test\n" }, { "from": "human", "value": "// Copyright 2012 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licen...
rust
chosen
[ { "from": "human", "value": "Add test to ensure unadjusted stays unstable\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under t...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 30\n" }, { "from": "gpt", "value": "#[macro_use] extern crate libeuler;\n\n/// Surprisingly there are only three numbers that can be written as the sum of fourth powers of\n/// their digits:\n///\n/// 1634 = 1^4 + 6^4 + 3^4 + 4^4\n/// ...
rust
chosen
[ { "from": "human", "value": "Add ui test for writing anyhow instead of bail\n\nCurrently fails:\n\n Expected test case to fail to compile, but it succeeded.\n" }, { "from": "gpt", "value": "#![deny(unused_must_use)]\n\nuse anyhow::anyhow;\n\nfn main() -> anyhow::Result<()> {\n if true {\n ...
rust
chosen
[ { "from": "system", "value": "Add `::current` module for whichever of `bits{32,64}` is active\n" }, { "from": "human", "value": "#![cfg(any(target_arch=\"x86\", target_arch=\"x86_64\"))]\n\n#![feature(const_fn)]\n#![feature(asm)]\n#![feature(associated_consts)]\n#![no_std]\n#![cfg_attr(test, all...
rust
chosen
[ { "from": "human", "value": "Add const generics tests for supertraits + dyn traits.\n" }, { "from": "gpt", "value": "// check-pass\n// revisions: full min\n\n#![cfg_attr(full, feature(const_generics))]\n#![cfg_attr(full, allow(incomplete_features))]\n#![cfg_attr(min, feature(min_const_generics))...
rust
chosen
[ { "from": "human", "value": "Add rust code for minesweeper case\n\nIt passsed all testcases\n" }, { "from": "gpt", "value": "#[inline]\nfn neighbors(x: usize, y: usize, width: usize, height: usize) -> Vec<(usize, usize)> {\n let mut result = Vec::new();\n\n if x != 0 && y != 0 {\n r...
rust
chosen
[ { "from": "human", "value": "Add a test for mismatched types when comparing functions\n" }, { "from": "gpt", "value": "// xfail-stage0\n// error-pattern:expected fn() but found fn(int)\n\nfn main() {\n fn f() {}\n fn g(int i) {}\n auto x = f == g;\n}" } ]
rust
chosen
[ { "from": "system", "value": "Add $ and 0 commands\n" }, { "from": "human", "value": "use super::*;\nuse redox::*;\n\nimpl Editor {\n pub fn exec(&mut self, Inst(n, cmd): Inst) {\n use super::Mode::*;\n use super::PrimitiveMode::*;\n use super::CommandMode::*;\n ma...
rust
chosen
[ { "from": "human", "value": "test: Add a crust function stress test\n" }, { "from": "gpt", "value": "// This creates a bunch of yielding tasks that run concurrently\n// while holding onto C stacks\n\nnative mod rustrt {\n fn rust_dbg_call(cb: *u8,\n data: ctypes::uintptr_t...
rust
chosen
[ { "from": "human", "value": "Add example for embedded named R function call.\n" }, { "from": "gpt", "value": "extern crate libc;\nextern crate libr;\nuse libc::c_int;\nuse std::ptr;\nuse std::env;\nuse std::ffi::{CStr, CString};\n\nuse libr::ffi::internals::*;\nuse libr::ffi::embedded::{self, Rf...
rust
chosen
[ { "from": "human", "value": "Test that associated types are not required as type parameters\n\nCloses #18173\n" }, { "from": "gpt", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/...
rust
chosen
[ { "from": "human", "value": "Add ATM example from paper\n" }, { "from": "gpt", "value": "#[macro_use] extern crate session_types;\nuse session_types::*;\nuse std::thread::spawn;\n\ntype Id = String;\ntype Atm = Recv<Id, Choose<Rec<AtmInner>, Eps>>;\n\ntype AtmInner = Offer<AtmDeposit,\n ...
rust
chosen
[ { "from": "human", "value": "incr.comp.: Add test case for dependency graph of type aliases.\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n...
rust
chosen
[ { "from": "human", "value": "Add solutions for day 11.\n" }, { "from": "gpt", "value": "extern crate aoc;\n\nfn increment(s: &mut [u8]) {\n let mut i = s.len() - 1;\n\n while s[i] == b'z' {\n if i == 0 {\n panic!(\"can't increment without adding new letter\");\n }\...
rust
chosen
[ { "from": "system", "value": "Use an array to label all commands and add `ptr_write` command\n" }, { "from": "human", "value": "use std::{io, fs};\n\nmacro_rules! readln {\n () => {\n {\n let mut line = String::new();\n match io::stdin().read_line(&mut line) {\n ...
rust
chosen
[ { "from": "human", "value": "Add test for new implementations section title\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n\npub struct Struc;\n\n// @has foo/struct.Struc.html\n// @has - '//*[@id=\"main\"]/h2[@id=\"implementations\"]' \"Implementations\"\nimpl Struc {\n pub const ...
rust
chosen
[ { "from": "human", "value": "Add integration test checking false positive rate\nand also includes a simple check for no false negatives.\n" }, { "from": "gpt", "value": "extern crate cuckoofilter;\nuse cuckoofilter::CuckooFilter;\nuse std::collections::hash_map::DefaultHasher;\n\n// Modelled aft...
rust
chosen
[ { "from": "system", "value": "Fix Rust 2018 idiom warning\n\nwith `cargo fix --all-features`\n" }, { "from": "human", "value": "//! Implements traits from Diesel, allowing identifiers to be used as database fields.\n\nuse std::{convert::TryFrom, error::Error as StdError, io::Write};\n\nuse diese...
rust
chosen
[ { "from": "system", "value": "Print only every 100th iteration\n" }, { "from": "human", "value": "extern crate rand;\n\nuse rand::thread_rng;\nuse rand::distributions::Range;\nuse individual::Individual;\n\nmod individual;\n\nfn main() {\n let mut rng = thread_rng();\n let range = Range::n...
rust
chosen
[ { "from": "human", "value": "Add test for cross crate newtype struct in match pattern.\n" }, { "from": "gpt", "value": "// Copyright 2013 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Lic...
rust
chosen
[ { "from": "human", "value": "Test drop order for (destructuring) assignments\n" }, { "from": "gpt", "value": "// run-pass\n\n//! Test that let bindings and destructuring assignments have consistent drop orders\n\n#![feature(destructuring_assignment)]\n#![allow(unused_variables, unused_assignment...
rust
chosen
[ { "from": "human", "value": "Add rust code for roman-numerals case\n\nIt passes all testcases\n" }, { "from": "gpt", "value": "#[derive(Debug)]\npub struct Roman {\n value: u32,\n}\n\nimpl From<u32> for Roman {\n #[inline]\n fn from(v: u32) -> Roman {\n Roman { value: v }\n }\...
rust
chosen
[ { "from": "human", "value": "Add test for unused field in union\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache ...
rust
chosen
[ { "from": "human", "value": "Create an example for recursive Levenshtein\n" }, { "from": "gpt", "value": "extern crate code;\n\nuse code::levenshtein;\n\nfn main() {\n let u = \"kangaroo\";\n let v = \"koala\";\n\n let distance = levenshtein::recursive(u, v);\n\n println!(\"distance ...
rust
chosen
[ { "from": "human", "value": "Add rust code for acronym case\n\nIt passes all tests\n" }, { "from": "gpt", "value": "pub fn abbreviate<S>(name: S) -> String where S: Into<String> {\n let mut next_capital = true;\n let mut prev_lowercase = false;\n\n name.into()\n .chars()\n ...
rust
chosen
[ { "from": "human", "value": "Add rust code for atbash-cipher\n\nIt passed all testcase\n" }, { "from": "gpt", "value": "#![feature(ascii_ctype)]\nuse std::ascii::AsciiExt;\n\npub fn encode(message: &str) -> String {\n let mut index = 0;\n message\n .chars()\n .filter_map(|c| ...
rust
chosen
[ { "from": "human", "value": "Add tests for Ident::new and Ident::parse\n" }, { "from": "gpt", "value": "// Copyright 2018 Syn Developers\n//\n// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n// <LICENSE-MIT o...
rust
chosen
[ { "from": "human", "value": "Add rust code for armstrong-numbers\n\nIt passed all tests\n" }, { "from": "gpt", "value": "pub fn is_armstrong_number(num: u32) -> bool {\n let mut result = num;\n let mut numbers = Vec::new();\n\n while result > 0 {\n numbers.push(result % 10);\n ...
rust
chosen
[ { "from": "human", "value": "Add wildcard test for const_if_match\n\nCloses https://github.com/rust-lang/rust/issues/66758\n" }, { "from": "gpt", "value": "// check-pass\n\n#![feature(const_if_match)]\n\nenum E {\n A,\n B,\n C\n}\n\nconst fn f(e: E) -> usize {\n match e {\n _ ...
rust
chosen
[ { "from": "human", "value": "Add auto trait leakage TAIT test\n" }, { "from": "gpt", "value": "// check-pass\n\n#![feature(type_alias_impl_trait)]\n#![allow(dead_code)]\n\nmod m {\n type Foo = impl std::fmt::Debug;\n\n pub fn foo() -> Foo {\n 22_u32\n }\n}\n\nfn is_send<T: Send>(...
rust
chosen
[ { "from": "human", "value": "Add test for Location::caller in a macro.\n" }, { "from": "gpt", "value": "// run-pass\n\n#![feature(track_caller)]\n\nmacro_rules! caller_location_from_macro {\n () => (core::panic::Location::caller());\n}\n\nfn main() {\n let loc = core::panic::Location::call...
rust
chosen
[ { "from": "human", "value": "Add test case for exported macros vs incremental compilation.\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n//...
rust
chosen
[ { "from": "human", "value": "Add benchmarks for statement cache.\n" }, { "from": "gpt", "value": "#![feature(test)]\nextern crate test;\n\nextern crate rusqlite;\n\nuse rusqlite::Connection;\nuse rusqlite::cache::StatementCache;\nuse test::Bencher;\n\n#[bench]\nfn bench_no_cache(b: &mut Bencher)...
rust
chosen
[ { "from": "human", "value": "Test for unsafe code in TLS macro\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache L...
rust
chosen