conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add test for async/await combined with const-generics.\n" }, { "from": "gpt", "value": "// edition:2018\n// check-pass\n// revisions: full min\n#![cfg_attr(full, feature(const_generics))]\n#![cfg_attr(full, allow(incomplete_features))]\n#![cfg_attr(min, feature(min_c...
rust
chosen
[ { "from": "human", "value": "test(vm): Add a test to check that marshalled references cannot escape\n" }, { "from": "gpt", "value": "extern crate embed_lang;\nuse embed_lang::new_vm;\nuse embed_lang::vm::vm::Value;\nuse embed_lang::vm::api::{VMType, Getable};\nuse embed_lang::vm::gc::Traverseabl...
rust
chosen
[ { "from": "human", "value": "Create a example PPM program\n\nThe program outputs a checkerboard\n" }, { "from": "gpt", "value": "extern crate scratchapixel;\n\nuse std::fs::File;\n\nuse scratchapixel::ppm::rgb::RGB;\nuse scratchapixel::ppm::format::PPM;\n\n\nfn main() {\n let white = RGB { r:...
rust
chosen
[ { "from": "human", "value": "Add GitError algebraic data type\n" }, { "from": "gpt", "value": "use std::fmt;\n\npub enum GitError {\n CorruptedRepository(&'static str),\n CorruptedCommit(&'static str)\n}\n\nimpl fmt::Show for GitError {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Re...
rust
chosen
[ { "from": "human", "value": "Add redirector to simplify imports.\n" }, { "from": "gpt", "value": "/* This file exists just to make it easier to import things inside of\n ./geom/ without specifying the file they came out of imports.\n \nNote that you still must define each of the files as a modul...
rust
chosen
[ { "from": "human", "value": "Add test to check that we do not get a cycle due to resolving `Self::Bar` in the where clauses\n" }, { "from": "gpt", "value": "// check-pass\n\n// Test that we do not get a cycle due to\n// resolving `Self::Bar` in the where clauses\n// on a trait definition (in par...
rust
chosen
[ { "from": "system", "value": "Update for changes in rustc.\n" }, { "from": "human", "value": "#![feature(\n btree_range,\n collections,\n collections_bound,\n question_mark,\n rustc_private,\n pub_restricted,\n)]\n\n// From rustc.\n#[macro_use] extern crate rustc;\nextern crate...
rust
chosen
[ { "from": "human", "value": "Check in a forgotten new file\n" }, { "from": "gpt", "value": "import syntax::ast::*;\nimport syntax::visit;\nimport driver::session::session;\n\ntype ctx = {in_loop: bool, can_ret: bool};\n\nfn check_crate(sess: session, crate: @crate) {\n visit::visit_crate(*cra...
rust
chosen
[ { "from": "human", "value": "Add test for none-delimited attribute on an item\n" }, { "from": "gpt", "value": "#[macro_use]\nmod macros;\n\nuse proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};\nuse quote::quote;\nuse std::iter::FromIterator;\nuse syn::Item;\n\n#[test]\nfn te...
rust
chosen
[ { "from": "human", "value": "Add a testkit for HTTP cache integration tests.\n\nDerived from cargo's.\n" }, { "from": "gpt", "value": "use std::cell::Cell;\nuse std::env;\nuse std::fs;\nuse std::path::PathBuf;\nuse std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};\n\nfn global_test_...
rust
chosen
[ { "from": "human", "value": "Test that fn preconditions get typechecked\n" }, { "from": "gpt", "value": "// Tests that the typechecker checks constraints\n// error-pattern:mismatched types: expected uint but found u8\nuse std;\nimport std::uint;\n\nfn enum_chars(start:u8, end:u8) : uint::le(star...
rust
chosen
[ { "from": "human", "value": "Add another test for !\n" }, { "from": "gpt", "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// Licensed under the Apache License, Ver...
rust
chosen
[ { "from": "human", "value": "Add a test case for previous commit\n" }, { "from": "gpt", "value": "// -*- rust -*-\n// xfail-pretty\n\nenum color {\n red,\n green,\n blue\n}\n\nfn main() {\n log(error, alt red {\n red => { 1 }\n green => { 2 }\n blue => { 3 }\n ...
rust
chosen
[ { "from": "human", "value": "Add a test for unique boxes as fn args\n\nIssue #409\n" }, { "from": "gpt", "value": "fn f(i: ~int) {\n assert *i == 100;\n}\n\nfn main() {\n f(~100);\n let i = ~100;\n f(i);\n}" } ]
rust
chosen
[ { "from": "human", "value": "Add test for assoc consts.\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 a regression test for FromIterator of OscArray\n" }, { "from": "gpt", "value": "extern crate rosc;\n\nuse rosc::{OscArray, OscType};\n\n#[test]\nfn test_osc_array_from_iter() {\n use std::iter::FromIterator;\n let iter = (0..3).map(|i| OscType::Int(i));\n ...
rust
chosen
[ { "from": "human", "value": "Add rust code for perfect-numbers\n\nIt passed all test cases\n" }, { "from": "gpt", "value": "#[derive(Debug, PartialEq)]\npub enum Classification {\n Perfect,\n Abundant,\n Deficient,\n}\n\npub fn classify(number: u64) -> Result<Classification, &'static st...
rust
chosen
[ { "from": "human", "value": "Add test for fix duplicate display of E0502\n" }, { "from": "gpt", "value": "// Copyright 2017 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 th...
rust
chosen
[ { "from": "human", "value": "Add test for uint and negative literals as discriminants\n" }, { "from": "gpt", "value": "enum Animal {\n Cat = 0u,\n Dog = 1u,\n Horse = 2u,\n Snake = 3u\n}\n\nenum Hero {\n Batman = -1,\n Superman = -2,\n Ironman = -3,\n Spiderman = -4\n}\n\...
rust
chosen
[ { "from": "system", "value": "Use NOTE instead of error-pattern directive\n" }, { "from": "human", "value": "// Copyright 2017 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 7 segment display example\n" }, { "from": "gpt", "value": "#![no_std]\n\nextern crate tock;\n\nconst DATA_PIN: u32 = 0;\nconst CLOCK_PIN: u32 = 1;\nconst LATCH_PIN: u32 = 2;\nconst SPEED: u32 = 2;\n\nuse tock::{led, timer};\n\nfn push_one_bit(value: bool) {\n ...
rust
chosen
[ { "from": "human", "value": "Test for a particular parallel codegen corner case\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 u...
rust
chosen
[ { "from": "human", "value": "Add a regression test for the const eval type resolution\n" }, { "from": "gpt", "value": "// Copyright 2017 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// Lice...
rust
chosen
[ { "from": "human", "value": "Add command for FLAC metdata\n\nFor now it only prints stream info\n" }, { "from": "gpt", "value": "extern crate docopt;\nextern crate flac;\nextern crate rustc_serialize;\n\nuse docopt::Docopt;\nuse flac::{ReadStream, Stream, StreamProducer};\n\nuse std::env;\nuse s...
rust
chosen
[ { "from": "human", "value": "Add day 25 part 1 solution\n" }, { "from": "gpt", "value": "// advent25.rs\n// copy protection code\n\n#[macro_use] extern crate scan_fmt;\n\nuse std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).ok().expect(\"Failed t...
rust
chosen
[ { "from": "human", "value": "Add tests for macros hygiene\n" }, { "from": "gpt", "value": "#[test]\nfn iproduct_hygiene() {\n let _ = itertools::iproduct!(0..6);\n let _ = itertools::iproduct!(0..6, 0..9);\n let _ = itertools::iproduct!(0..6, 0..9, 0..12);\n}\n\n#[test]\nfn izip_hygiene...
rust
chosen
[ { "from": "human", "value": "Add Rust solution for bubblesort\n" }, { "from": "gpt", "value": "use std::cmp::PartialOrd;\n\n/// An in-place implementation of bubble sort\nfn bubble_sort<T>(arr: &mut [T])\nwhere T: PartialOrd {\n for i in 0..arr.len() {\n for j in i..arr.len() {\n if arr...
rust
chosen
[ { "from": "human", "value": "Add a simple decoder benchmark\n" }, { "from": "gpt", "value": "#![feature(test)]\nextern crate test;\nextern crate rosc;\n\nuse self::test::Bencher;\n\n#[bench]\nfn bench_decode(b: &mut Bencher) {\n // The message was captured from the `ytterbium` lemur patch loo...
rust
chosen
[ { "from": "human", "value": "Add test to deserialize unsigned int\n\nSigned-off-by: Matthias Beyer <1d6e1cf70ec6f9ab28d3ea4b27a49a77654d370e@beyermatthias.de>\n" }, { "from": "gpt", "value": "#![cfg(feature = \"preserve_order\")]\n\nextern crate indexmap;\n\n#[derive(serde::Deserialize, Eq, Part...
rust
chosen
[ { "from": "human", "value": "Add test for Command::current_dir behavior.\n" }, { "from": "gpt", "value": "// run-pass\n// ignore-emscripten no processes\n// ignore-sgx no processes\n\nuse std::env;\nuse std::fs;\nuse std::path::Path;\nuse std::process::Command;\n\nfn main() {\n // Checks the ...
rust
chosen
[ { "from": "human", "value": "Add some XML character predicates\n" }, { "from": "gpt", "value": "use super::{Document,Root,RootChild};\n\ntrait XmlChar {\n fn is_name_start_char(&self) -> bool;\n fn is_name_char(&self) -> bool;\n}\n\nimpl XmlChar for char {\n fn is_name_start_char(&self)...
rust
chosen
[ { "from": "human", "value": "Add test for associated const version display\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 ...
rust
chosen
[ { "from": "human", "value": "Add regression test for atomics being Send + Sync\n\nThanks to Tamir Duberstein for the implementation suggestion.\n" }, { "from": "gpt", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distributi...
rust
chosen
[ { "from": "human", "value": "Add test for --remap-path-prefix on std imports\n" }, { "from": "gpt", "value": "// ignore-windows\n\n// compile-flags: -g -C no-prepopulate-passes --remap-path-prefix=/=/the/root/\n\n// Here we check that imported code from std has their path remapped\n\n// CHECK: ...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 37\n" }, { "from": "gpt", "value": "#![feature(core)]\n#[macro_use] extern crate libeuler;\nextern crate num;\n\nuse libeuler::SieveOfAtkin;\nuse num::traits::PrimInt;\n\n/// The number 3797 has an interesting property. Being prime itself, it ...
rust
chosen
[ { "from": "human", "value": "Add temporary parser for /proc/sys/fs/file-max\n" }, { "from": "gpt", "value": "// NOTE: I'll open a PR on procinfo-rs to parse /proc/sys/fs/file-max\n// in the meantime, I wrote it here\n// Arnaud Lefebvre - 23/02/17\n\nuse std::fs::File;\nuse std::io::{Read, Error,...
rust
chosen
[ { "from": "human", "value": "Add a test for error_on_line_overflow_strings\n" }, { "from": "gpt", "value": "// rustfmt-error_on_line_overflow_strings: false\n// Suppress an error on line overflow strings.\n\nfn main() {\n let x = \" ...
rust
chosen
[ { "from": "human", "value": "Add failing use case for CubeMapArray type in shaders.\n\nThis is because of missing UniformType mapping.\n" }, { "from": "gpt", "value": "#[macro_use]\nextern crate glium;\n\nmod support;\n\n// Tests for support of the cube map array type in programs.\nfn program_su...
rust
chosen
[ { "from": "human", "value": "Add simple vertex buffer tests\n\ncc #15\n" }, { "from": "gpt", "value": "#![feature(phase)]\n\n#[phase(plugin)]\nextern crate glium_macros;\n\nextern crate glutin;\nextern crate glium;\n\nuse glium::DisplayBuild;\n\n#[test]\nfn vertex_buffer_creation() {\n #[vert...
rust
chosen
[ { "from": "human", "value": "Add syntactic test for rest patterns.\n" }, { "from": "gpt", "value": "// Here we test that `..` is allowed in all pattern locations *syntactically*.\n// The semantic test is in `rest-pat-semantic-disallowed.rs`.\n\n// check-pass\n\nfn main() {}\n\nmacro_rules! accep...
rust
chosen
[ { "from": "human", "value": "Add codegen test to make sure that closures are 'internalized' properly.\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/COPYRIG...
rust
chosen
[ { "from": "human", "value": "Add test for duplicate definitions of structs and enum struct variants.\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/COPYRIGH...
rust
chosen
[ { "from": "human", "value": "Add a missing file that defines the `Unit` type.\n" }, { "from": "gpt", "value": "use traits::geometry::Norm;\n\n\n/// A wrapper that ensures the undelying algebraic entity has a unit norm.\n#[repr(C)]\n#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, H...
rust
chosen
[ { "from": "human", "value": "Add exercise 6.5 - strftime\n" }, { "from": "gpt", "value": "/// Exercise: Write a program to obtain the current time and print it using strftime,\n/// so that it looks like the default output from date(1). Set the TZ environment\n/// variable to different values and...
rust
chosen
[ { "from": "human", "value": "Add test demonstrating context inference failure\n" }, { "from": "gpt", "value": "use anyhow::{Context, Result};\n\n// https://github.com/dtolnay/anyhow/issues/18\n#[test]\nfn test_inference() -> Result<()> {\n let x = \"1\";\n let y: u32 = x.parse().context(\"...
rust
chosen
[ { "from": "human", "value": "Create an example for the client module.\n" }, { "from": "gpt", "value": "// Copyright 2020 Google LLC\n//\n// Use of this source code is governed by an MIT-style license that can be found\n// in the LICENSE file or at https://opensource.org/licenses/MIT.\n\nfn main(...
rust
chosen
[ { "from": "human", "value": "Add a test for deprecated phase(syntax)\n" }, { "from": "gpt", "value": "// Copyright 2013-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 t...
rust
chosen
[ { "from": "human", "value": "Add rustdoc regression test for the unused_braces lint\n" }, { "from": "gpt", "value": "// check-pass\n\n// This tests the bug in #70814, where the unused_braces lint triggered on the following code\n// without providing a span.\n\n#![deny(unused_braces)]\n\nfn main(...
rust
chosen
[ { "from": "human", "value": "Add a simple trait for single time parsing\n\nThis is inspired by the chomp project <https://github.com/m4rw3r/chomp>.\n" }, { "from": "gpt", "value": "use nom::IResult;\n\npub trait StreamProducer {\n fn parse<F, T>(&mut self, f: F) -> Result<T, ErrorKind>\n wher...
rust
chosen
[ { "from": "human", "value": "Add a compile-fail test for attempts to extend non-objects.\n" }, { "from": "gpt", "value": "//error-pattern:x does not have object type\nuse std;\n\nfn main() {\n auto x = 3;\n\n auto anon_obj = obj {\n fn foo() -> int {\n ret 3;\n }\n...
rust
chosen
[ { "from": "human", "value": "Add EntryHeader type for store\n" }, { "from": "gpt", "value": "use toml::Table;\n\npub struct EntryHeader {\n toml: Table,\n}\n\nimpl EntryHeader {\n\n pub fn new(toml: Table) -> EntryHeader {\n EntryHeader {\n toml: toml,\n }\n }\n...
rust
chosen
[ { "from": "human", "value": "Add test for associated constants in the sidebar\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n\npub trait Trait {\n const FOO: u32 = 12;\n\n fn foo();\n}\n\npub struct Bar;\n\n// @has 'foo/struct.Bar.html'\n// @has - '//h3[@class=\"sidebar-title\"...
rust
chosen
[ { "from": "system", "value": "test: Fix depcrecated alias for int\n" }, { "from": "human", "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 Apa...
rust
chosen
[ { "from": "human", "value": "test: Add a test for trait inheritance with self as a type parameter. rs=test-only\n" }, { "from": "gpt", "value": "trait Foo<T> {\n fn f(&self, x: &T);\n}\n\ntrait Bar : Foo<self> {\n fn g(&self);\n}\n\nstruct S {\n x: int\n}\n\nimpl S : Foo<S> {\n fn f(...
rust
chosen
[ { "from": "human", "value": "Add test for `Ipv6Addr` methods in a const context\n" }, { "from": "gpt", "value": "// run-pass\n\n#![feature(ip)]\n#![feature(const_ipv6)]\n\nuse std::net::{Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};\n\nfn main() {\n const IP_ADDRESS : Ipv6Addr = Ipv6Addr::new(0, 0...
rust
chosen
[ { "from": "human", "value": "Solve Simple Sum in rust\n" }, { "from": "gpt", "value": "use std::io;\n\nfn main() {\n let mut input_a = String::new();\n let mut input_b = String::new();\n\n if let Err(_e) = io::stdin().read_line(&mut input_a){}\n if let Err(_e) = io::stdin().read_line...
rust
chosen
[ { "from": "human", "value": "Add simpler, but less performant decode example\n" }, { "from": "gpt", "value": "// Claxon -- A FLAC decoding library in Rust\n// Copyright 2017 Ruud van Asseldonk\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file...
rust
chosen
[ { "from": "human", "value": "Add an xfailed test for bogus deep copying of things containing resources\n" }, { "from": "gpt", "value": "// xfail-test\n// expected error: mismatched kinds\n\nresource r(i: @mutable int) {\n *i = *i + 1;\n}\n\nfn main() {\n let i = @mutable 0;\n {\n ...
rust
chosen
[ { "from": "human", "value": "Add test for E0152 error message improvement\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 t...
rust
chosen
[ { "from": "human", "value": "Add test for ICE 6793\n" }, { "from": "gpt", "value": "//! This is a reproducer for the ICE 6793: https://github.com/rust-lang/rust-clippy/issues/6793.\n//! The ICE is caused by using `TyCtxt::type_of(assoc_type_id)`, which is the same as the ICE 6792.\n\ntrait Trait...
rust
chosen
[ { "from": "human", "value": "Add a wrapper for C file descriptors\n" }, { "from": "gpt", "value": "extern crate libc;\nuse self::libc::{c_int, close};\nuse std::fmt;\n\n\npub struct CFileDescriptor {\n fd: c_int\n}\n\n\nimpl CFileDescriptor {\n pub fn new(fd: c_int) -> CFileDescriptor {\n ...
rust
chosen
[ { "from": "human", "value": "[Bonsai] Add the AST (missing file).\n" }, { "from": "gpt", "value": "// Copyright 2016 Pierre Talbot (IRCAM)\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obta...
rust
chosen
[ { "from": "human", "value": "Test for cast causing static promotion failure.\n\nThis commit adds a test that ensures that a cast in a static doesn't\nstop const promotion within the static.\n" }, { "from": "gpt", "value": "// Copyright 2017 The Rust Project Developers. See the COPYRIGHT\n// file...
rust
chosen
[ { "from": "system", "value": "Add simple test of assert_eq!.\n" }, { "from": "human", "value": "#![feature(custom_attribute, box_syntax)]\n#![allow(dead_code, unused_attributes)]\n\n#[miri_run]\nfn rc_cell() -> i32 {\n use std::rc::Rc;\n use std::cell::Cell;\n let r = Rc::new(Cell::new(...
rust
chosen
[ { "from": "human", "value": "Test that NRVO elides the call to `memcpy`\n" }, { "from": "gpt", "value": "// compile-flags: -O\n\n#![crate_type = \"lib\"]\n\n// Ensure that we do not call `memcpy` for the following function.\n// `memset` and `init` should be called directly on the return pointer....
rust
chosen
[ { "from": "system", "value": "Fix unit test that was illegally mutating an upvar\n" }, { "from": "human", "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// License...
rust
chosen
[ { "from": "system", "value": "Simplify `DSDT::new()` with fewer `unsafe` blocks\n" }, { "from": "human", "value": "use super::SDTHeader;\n\n#[repr(packed)]\n#[derive(Clone, Copy, Debug, Default)]\npub struct DSDT {\n pub header: SDTHeader,\n pub data: &'static [u8]\n\n}\n\nimpl DSDT {\n ...
rust
chosen
[ { "from": "human", "value": "Add test to ensure edge-triggering\n" }, { "from": "gpt", "value": "/// Ensure all sockets operate on edge trigger mode.\n\nextern crate amy;\n\nuse std::net::{TcpListener, TcpStream};\nuse std::thread;\nuse std::str;\nuse std::io::{Read, Write};\n\nuse amy::{\n P...
rust
chosen
[ { "from": "human", "value": "Add an XFAILed test for failing destructors\n\nIssue #236\n" }, { "from": "gpt", "value": "// error-pattern:fail\n// xfail-test\n\nresource r(i: int) {\n // What happens when destructors throw?\n fail;\n}\n\nfn main() {\n @0;\n let r <- r(0);\n}" } ]
rust
chosen
[ { "from": "human", "value": "Add Showcase program to test and demonstrate the library\n" }, { "from": "gpt", "value": "/* Copyright 2016 Jordan Miner\n *\n * Licensed under the MIT license <LICENSE or\n * http://opensource.org/licenses/MIT>. This file may not be copied,\n * modified, or distribu...
rust
chosen
[ { "from": "human", "value": "Bring in Phauxfiles argument handler without specifics\n" }, { "from": "gpt", "value": "use getopts::Options;\nuse std::env::Args;\n\npub struct Arguments {\n pub program_name: String,\n pub exit: bool,\n}\n\nfn print_usage(program: &str, opts: Options) {\n ...
rust
chosen
[ { "from": "system", "value": "Use pentium4 for base CPU on i686-pc-windows-msvc\n\nThis is in line with other targets.\r\n\r\nCloses #27646" }, { "from": "human", "value": "// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution a...
rust
chosen
[ { "from": "human", "value": "Add Rust code for proverb case\n\nIt passed all test cases\n" }, { "from": "gpt", "value": "pub fn build_proverb(text: Vec<&str>) -> String {\n let mut result = String::new();\n let mut iter = text.iter().peekable();\n\n let last = if text.len() < 3 { \"\" }...
rust
chosen
[ { "from": "human", "value": "Add dummy compilation test in replacement for examples\n" }, { "from": "gpt", "value": "//! This file contains a single test that is\n//! compiled but not run, just to ensure that\n//! the GL symbols are defined\n\nextern crate gl;\nextern crate libc;\n\n#[test]\n#...
rust
chosen
[ { "from": "human", "value": "Add a test for async closures\n" }, { "from": "gpt", "value": "// rustfmt-edition: Edition2018\n\nfn main() {\n let async_closure = async {\n let x = 3;\n x\n };\n\n let f = async /* comment */ {\n let x = 3;\n x\n };\n\n le...
rust
chosen
[ { "from": "human", "value": "Implement \"Roots of a function\" problem.\n" }, { "from": "gpt", "value": "// http://rosettacode.org/wiki/Roots_of_a_function\n\nfn find_roots<T: Copy + PartialOrd + Signed>(f: |T| -> T, start: T, stop: T,\n step: T, epsil...
rust
chosen
[ { "from": "human", "value": "Add example that utilizes terminal default colors\n" }, { "from": "gpt", "value": "extern crate cursive;\n\n\nuse cursive::Cursive;\nuse cursive::theme::{Color, Theme};\nuse cursive::views::TextView;\n\n\nfn custom_theme_from_cursive(siv: &Cursive) -> Theme {\n le...
rust
chosen
[ { "from": "human", "value": "Add test for two sequence repetitions in a row\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...
rust
chosen
[ { "from": "human", "value": "Add the commandline options example from the README to examples\n" }, { "from": "gpt", "value": "extern crate getopts;\nextern crate knob;\n\nuse getopts::optopt;\nuse knob::Settings;\n\nfn main() {\n let mut settings = Settings::new();\n settings.opt(optopt(\"...
rust
chosen
[ { "from": "human", "value": "Add a test for unsized tuple impls.\n" }, { "from": "gpt", "value": "// Copyright 2017 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": "Implement a trait that get an HTTP response given an URL and headers\n" }, { "from": "gpt", "value": "use hyper::client::Client;\nuse hyper::client::response::Response;\nuse hyper::error::Error;\nuse hyper::header::Headers;\nuse hyper::method::Method;\n\n/// Trait th...
rust
chosen
[ { "from": "human", "value": "Add a prototype of the digest FFI API.\n" }, { "from": "gpt", "value": "extern crate ring;\n\nmacro_rules! wrap_algorithm {\n ( $wrapper_name:ident, $t:ty, $alg:expr ) => {\n /// Do NOT free the resulting pointer.\n #[no_mangle]\n pub unsafe f...
rust
chosen
[ { "from": "system", "value": "Replace is_none() -> unwrap() with unwrap_or_else()\n" }, { "from": "human", "value": "use std::process::exit;\n\nuse libimagdiary::diary::Diary;\nuse libimagentryview::viewer::Viewer;\nuse libimagentryview::builtin::plain::PlainViewer;\nuse libimagrt::runtime::Runt...
rust
chosen
[ { "from": "human", "value": "Add 3rd example, simple linked list and move\n" }, { "from": "gpt", "value": "enum SimpleList<T> {\n Cons(T, Box<SimpleList<T>>),\n Nil,\n}\n\nfn length<T>(xs: &SimpleList<T>) -> int {\n match xs {\n &Cons(_, ref ys) => 1 + length(*ys),\n &Nil ...
rust
chosen
[ { "from": "human", "value": "Add example for merge requests\n" }, { "from": "gpt", "value": "\nextern crate gitlab_api as gitlab;\n\nuse std::env;\n#[macro_use]\nextern crate log;\nextern crate env_logger;\n\nuse gitlab::GitLab;\nuse gitlab::merge_requests;\n\n\nfn main() {\n env_logger::init...
rust
chosen
[ { "from": "human", "value": "Add tests for null pointer opt.\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 Apache Lic...
rust
chosen
[ { "from": "human", "value": "Add example from lkuper's intern talk to the test suite.\n" }, { "from": "gpt", "value": "// Example from lkuper's intern talk, August 2012.\n\ntrait Equal {\n fn isEq(a: self) -> bool;\n}\n\nenum Color { cyan, magenta, yellow, black }\n\nimpl Color : Equal {\n ...
rust
chosen
[ { "from": "human", "value": "Add a test to prevent regression\n\nThe way it defines implementations is unrealistic though.\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
chosen
[ { "from": "human", "value": "Add RMS example to the examples directory\n\nA similar example was already in the readme and the docs, but it is\nuseful to have a runnable program to test whether Hound can read a given\nfile.\n" }, { "from": "gpt", "value": "// Hound -- A wav encoding and decoding ...
rust
chosen
[ { "from": "human", "value": "Add an XFAILed test for native \"llvm\" modules\n\nThis functionality is completely broken\n" }, { "from": "gpt", "value": "// xfail-test\n\nnative \"llvm\" mod llvm {\n fn thesqrt(n: float) -> float = \"sqrt.f64\";\n}\n\nfn main() {\n let s = llvm::thesqrt(4.0...
rust
chosen
[ { "from": "human", "value": "Add a FIXME note about what's missing\n" }, { "from": "gpt", "value": "// ignore-test\n\n#![allow(incomplete_features)]\n#![feature(const_mut_refs)]\n#![feature(inline_const)]\n\nuse std::marker::PhantomData;\n\n#[derive(PartialEq, Eq)]\npub struct InvariantRef<'a, T...
rust
chosen
[ { "from": "human", "value": "Test against accesses to uninitialized fields.\n" }, { "from": "gpt", "value": "// Copyright 2017 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 an unit test for add_global_mapping.\n" }, { "from": "gpt", "value": "extern crate libc;\nextern crate llvm;\n\nuse libc::c_void;\nuse llvm::*;\nuse std::mem;\n\npub extern \"C\" fn test_func3(x: f64) -> f64 {\n x\n}\n\n#[test]\nfn add_global_mapping() {\n let ...
rust
chosen
[ { "from": "system", "value": "Add a fat byte-slice coercion test.\n" }, { "from": "human", "value": "#![feature(custom_attribute)]\n#![allow(dead_code, unused_attributes)]\n\n#[miri_run]\nfn empty() -> &'static str {\n \"\"\n}\n\n#[miri_run]\nfn hello() -> &'static str {\n \"Hello, world!\...
rust
chosen
[ { "from": "human", "value": "Add test for comparing md5 checksums\n" }, { "from": "gpt", "value": "extern crate flac;\nextern crate crypto;\n\nuse crypto::digest::Digest;\nuse crypto::md5::Md5;\nuse flac::Stream;\nuse std::cmp;\n\nfn to_bytes(value: i32, buffer: &mut [u8]) {\n buffer[0] = value...
rust
chosen
[ { "from": "system", "value": "test: Fix problem with check-fast. rs=burningtree\n" }, { "from": "human", "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...
rust
chosen
[ { "from": "human", "value": "Add test for macro disambiguators\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n#![deny(rustdoc::broken_intra_doc_links)]\n\n//! [foo!()]\n// @has foo/index.html '//a[@href=\"macro.foo.html\"]' 'foo!()'\n\n//! [foo!{}]\n// @has - '//a[@href=\"macro.foo.h...
rust
chosen
[ { "from": "human", "value": "Add integration test for macro\n" }, { "from": "gpt", "value": "//! Having these as an integration test checks that the visibility of the macros\n//! and their dependencies is valid for use by external libraries.\n\n#[macro_use]\n// Rename the import to check that th...
rust
chosen
[ { "from": "human", "value": "Add a test file for distinct ty_native types\n\nThis should have gone into patch\n77f5d14f14630da997f13de28ea86e8320957180, had I not forgotten to add\nthe file.\n" }, { "from": "gpt", "value": "// error-pattern:expected native but found native\nuse std;\n\nfn main()...
rust
chosen
[ { "from": "human", "value": "Add a test for exported symbols.\n" }, { "from": "gpt", "value": "// Copyright 2016 Mozilla\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\n// this file except in compliance with the License. You may obtain a copy of the\n//...
rust
chosen