conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "testsuite: Test that init and forget are both unsafe\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...
rust
chosen
[ { "from": "human", "value": "test: Add test for LHS expression check\n" }, { "from": "gpt", "value": "// Copyright 2012-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 t...
rust
chosen
[ { "from": "human", "value": "Add rather slow solution to problem 25\n" }, { "from": "gpt", "value": "#[macro_use] extern crate libeuler;\nextern crate num;\n\nuse num::traits::Zero;\nuse num::traits::One;\nuse num::bigint::BigUint;\nuse std::mem::replace;\n\n/// The Fibonacci sequence is defined...
rust
chosen
[ { "from": "human", "value": "test: Add a test for regions, traits, and variance.\n\nCloses #12470.\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....
rust
chosen
[ { "from": "human", "value": "Add a simple encoding example\n" }, { "from": "gpt", "value": "// Encode the same tiny blank frame 30 times\nuse rav1e::*;\n\nfn main() {\n let mut cfg = Config::default();\n\n cfg.enc.width = 64;\n cfg.enc.height = 96;\n\n cfg.enc.speed_settings = SpeedSettings:...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 69\n" }, { "from": "gpt", "value": "#[macro_use] extern crate libeuler;\n\nuse libeuler::prime::SieveOfAtkin;\n/// Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the\n/// number of numbers less than n ...
rust
chosen
[ { "from": "system", "value": "test: Add tests for multiple outer attributes on items\n\nIssue #487\n" }, { "from": "human", "value": "// xfail-stage0\n\n#[attr = \"val\"]\nconst int x = 10;\n\n#[attr = \"val\"]\nmod mod1 {\n}\n\n#[attr = \"val\"]\nnative \"rust\" mod rustrt {\n}\n\n#[attr = \"va...
rust
chosen
[ { "from": "human", "value": "Add regression test for old NLL ICE\n" }, { "from": "gpt", "value": "// check-pass\n\n#![crate_type = \"lib\"]\n\n// In an older version, when NLL was still a feature, the following previously did not compile\n// #![feature(nll)]\n\nuse std::ops::Index;\n\npub struct...
rust
chosen
[ { "from": "human", "value": "Add a single function to get the length of a chunk, based on his index, and a few simple unit tests\n" }, { "from": "gpt", "value": "use std::cmp::min;\n\nuse Byte;\n\n/// Represents a range between two Byte types\n#[derive(Debug, PartialEq)]\nstruct RangeBytes(Byte,...
rust
chosen
[ { "from": "human", "value": "Add and xfail test for 2101\n" }, { "from": "gpt", "value": "// xfail-test\nuse std;\nimport std::arena;\nimport std::arena::arena;\n\nenum hold { s(str) }\n\nfn init(ar: &a.arena::arena, str: str) -> &a.hold {\n new(*ar) s(str)\n}\n\nfn main(args: [str]) {\n l...
rust
chosen
[ { "from": "human", "value": "Create an example for node executing instructions\n" }, { "from": "gpt", "value": "extern crate tis_100_superoptimizer;\n\nuse tis_100_superoptimizer::TIS_100::{Node,Instruction,Source,Destination};\n\nfn main() {\n let node: Node = Node::new();\n let last: Nod...
rust
chosen
[ { "from": "human", "value": "Add support for Linux cooked-mode capture (LINKTYPE_LINUX_SLL) packets\n\nAdd support for Linux cooked-mode capture (LINKTYPE_LINUX_SLL) packets\r\n\r\nCloses #510" }, { "from": "gpt", "value": "//! A Linux cooked-mode capture (LINKTYPE_LINUX_SLL) packet abstraction....
rust
chosen
[ { "from": "system", "value": "Fix Clippy and CI bug\n" }, { "from": "human", "value": "//! This is the main lib.rs file for Xt Core\n\n// This file is part of Xt.\n\n// This is the Xt text editor; it edits text.\n// Copyright (C) 2016-2017 The Xt Developers\n\n// This program is free software: ...
rust
chosen
[ { "from": "human", "value": "Add a test for the new raw writing API\n\nThis is mostly to ensure we don't break anything drastically.\n" }, { "from": "gpt", "value": "//! Tests for the raw write logging functionality.\nextern crate fern;\nextern crate log;\n\nuse std::io;\nuse std::sync::Arc;\nus...
rust
chosen
[ { "from": "human", "value": "Add tests for various ways to write 'do' and 'for' without args\n" }, { "from": "gpt", "value": "// no-reformat\n// Testing various forms of `do` and `for` with empty arg lists\n\nfn f(f: fn() -> bool) {\n}\n\nfn main() {\n do f() || { true }\n do f() { true }\...
rust
chosen
[ { "from": "human", "value": "process: Add regression test for signal starvation\n" }, { "from": "gpt", "value": "#![cfg(unix)]\n\nextern crate futures;\nextern crate tokio_process;\n\nuse futures::{Future, IntoFuture, Stream, stream};\nuse std::process::{Command, Stdio};\nuse std::sync::Arc;\nus...
rust
chosen
[ { "from": "human", "value": "rustc: Add a test case for previous commit\n" }, { "from": "gpt", "value": "tag opt[T] {\n none;\n}\n\nfn main() {\n auto x = none[int];\n alt (x) {\n case (none[int]) { log \"hello world\"; }\n }\n}\n\n" } ]
rust
chosen
[ { "from": "human", "value": "Add Breadth-First Search using The Rust Programming Language\n" }, { "from": "gpt", "value": "use std::io::stdin;\nuse std::collections::VecDeque;\n\n// DFS receives a graph and the start point\nfn bfs(graph: &mut Vec<Vec<usize>>, start: usize) {\n let mut visited...
rust
chosen
[ { "from": "system", "value": "Remove ColorCast trait for now\n" }, { "from": "human", "value": "use num;\n\npub trait Color: Clone + PartialEq {\n type Tag;\n type ChannelsTuple;\n\n fn num_channels() -> u32;\n fn from_tuple(values: Self::ChannelsTuple) -> Self;\n fn to_tuple(self...
rust
chosen
[ { "from": "system", "value": "Fix the sentence in the comment - was to want" }, { "from": "human", "value": "// Derive the `fmt::Debug` implementation for `Structure`. `Structure`\n// is a structure which contains a single `i32`.\n#[derive(Debug)]\nstruct Structure(i32);\n\n// Put a `Structure` ...
rust
chosen
[ { "from": "system", "value": "Add floating point normalized to screen coordinate conversion\n" }, { "from": "human", "value": "pub mod wireframe;\npub mod filled;\npub mod textured;\n\n/// Do perspective calculation on a point, return (x, y).\nfn perpective(x: f32, y: f32, z: f32) -> (f32, f32) ...
rust
chosen
[ { "from": "human", "value": "Add initial basic benchmark for header setters\n" }, { "from": "gpt", "value": "#![feature(test)]\n\nextern crate rips_packets;\nextern crate test;\n\nuse rips_packets::ethernet::{MutEthernetPacket, ether_types};\nuse rips_packets::ipv4::{self, MutIpv4Packet};\nuse r...
rust
chosen
[ { "from": "human", "value": "Add a test for std._vec.init_elt, and an XFAILed test for std._vec.init_fn.\n" }, { "from": "gpt", "value": "use std;\n\nfn test_init_elt() {\n let vec[uint] v = std._vec.init_elt[uint](uint(5), uint(3));\n check (std._vec.len[uint](v) == uint(3));\n check (v.(0) ...
rust
chosen
[ { "from": "system", "value": "Update i686-linux-android features to match android ABI.\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// L...
rust
chosen
[ { "from": "human", "value": "test: Add tests for sw_vers parsing\n" }, { "from": "gpt", "value": "extern crate regex;\n#[path=\"../src/sw_vers.rs\"]\nmod sw_vers;\n#[path=\"../src/utils.rs\"]\nmod utils;\n\nfn file() -> String {\n\"\nProductName:\tMac OS X\nProductVersion:\t10.10.5\nBuildVersion...
rust
chosen
[ { "from": "human", "value": "Add rust code for isbn-verifier\n\nIt passed all test cases\n" }, { "from": "gpt", "value": "#![feature(ascii_ctype)]\n\npub fn is_valid_isbn(isbn: &str) -> bool {\n let mut iter = isbn.chars().peekable();\n\n if let Some(&c) = iter.peek() {\n if !c.is_a...
rust
chosen
[ { "from": "human", "value": "Add a test for the osc decoder\n" }, { "from": "gpt", "value": "extern crate rosc;\n\nuse rosc::{types, errors, decoder, utils};\n\n#[test]\nfn test_decode() {\n let raw_addr = \"/some/valid/address/4\";\n let addr = pad(raw_addr.as_bytes());\n // args\n ...
rust
chosen
[ { "from": "human", "value": "Add rust code for say\n\nIt passed all testcases.\n" }, { "from": "gpt", "value": "const TEN: u64 = 10;\nconst HUNDRED: u64 = 100;\nconst THOUSAND: u64 = 1000;\n\nfn ntable(number: u64) -> &'static str {\n match number {\n 0 => \"zero\",\n 1 => \"one...
rust
chosen
[ { "from": "system", "value": "Fix ops example according to latest nightly" }, { "from": "human", "value": "struct Foo;\nstruct Bar;\n\n#[deriving(Show)]\nstruct FooBar;\n\n#[deriving(Show)]\nstruct BarFoo;\n\n// The `Add<T, U>` trait needs two generic parameters:\n// * T is the type of the RHS s...
rust
chosen
[ { "from": "human", "value": "Add file to section 2 of examples\n" }, { "from": "gpt", "value": "use std::mem;\n\n// This function borrows a slice\nfn analyze_slice(slice: &[i32]) {\n println!(\"first element: {}\", slice[0]);\n println!(\"slice has {} elements\", slice.len());\n}\n\nfn mai...
rust
chosen
[ { "from": "system", "value": "Fix expected error message in a test.\n\nThe change is a result of the char/string parsing refactor.\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...
rust
chosen
[ { "from": "human", "value": "examples: Add support for a simple CTAP example\n\nSigned-off-by: Alistair Francis <52ecf00b70a50079ae8d5fa09b9af6904950b63c@wdc.com>\n" }, { "from": "gpt", "value": "#![no_std]\n/// This is a very basic CTAP example\n/// This example only calls the CTAP driver calls...
rust
chosen
[ { "from": "human", "value": "Add regression test for duplicate items in overlapping impls. Note that a regression test already exists for *non*overlapping impls.\n" }, { "from": "gpt", "value": "// Copyright 2016 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory ...
rust
chosen
[ { "from": "system", "value": "Add ExtFmt test for unsigned type\n" }, { "from": "human", "value": "// xfail-boot\n// xfail-stage0\nuse std;\nimport std._str;\n\nfn test(str actual, str expected) {\n log actual;\n log expected;\n check (_str.eq(actual, expected));\n}\n\nfn main() {\n test(#fm...
rust
chosen
[ { "from": "human", "value": "Add tests for wrapping integers\n\nSigned-off-by: Matthias Beyer <1d6e1cf70ec6f9ab28d3ea4b27a49a77654d370e@beyermatthias.de>\n" }, { "from": "gpt", "value": "extern crate config;\n\nuse config::*;\n\n#[test]\nfn wrapping_u16() {\n let c = Config::builder()\n ...
rust
chosen
[ { "from": "system", "value": "Update test and un-xfail it\n" }, { "from": "human", "value": "// xfail-test #2587\n// error-pattern: copying a noncopyable value\n\nstruct r {\n let i:int;\n new(i:int) {self.i = i;}\n}\n\nimpl r : Drop {\n fn finalize() {}\n}\n\nfn main() {\n // This can't...
rust
chosen
[ { "from": "human", "value": "Test for incorrect remote type deserializing\n" }, { "from": "gpt", "value": "#[macro_use]\nextern crate serde_derive;\n\nmod remote {\n pub struct S(pub u16);\n}\n\n#[derive(Deserialize)] //~ ERROR: mismatched types\n#[serde(remote = \"remote::S\")]\nstruct S(u8)...
rust
chosen
[ { "from": "human", "value": "Add example of connection using TLS\n" }, { "from": "gpt", "value": "use ldap3::LdapConn;\n\nconst LDAPS_SERVER: &str = \"ldaps://directory.example.com:636\";\nconst LDAP_SERVICE_USER_DN: &str = \"CN=ldapuser,CN=Users,DC=example,DC=com\";\nconst LDAP_SERVICE_USER_PW:...
rust
chosen
[ { "from": "human", "value": "Add an example to render without Renderer\n" }, { "from": "gpt", "value": "extern crate sdl2;\n\nuse sdl2::pixels::Color;\nuse sdl2::event::Event;\nuse sdl2::keyboard::Keycode;\nuse sdl2::video::Window;\nuse sdl2::rect::Rect;\nuse std::time::Duration;\n\nconst WINDOW...
rust
chosen
[ { "from": "human", "value": "Add a test for vstore, which already works\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...
rust
chosen
[ { "from": "human", "value": "Add example with the code in tutorial 01\n" }, { "from": "gpt", "value": "#[macro_use]\nextern crate glium;\nextern crate glutin;\n\nfn main() {\n use glium::{DisplayBuild, Surface};\n let display = glutin::WindowBuilder::new().build_glium().unwrap();\n\n #[...
rust
chosen
[ { "from": "human", "value": "test: Add a test case for linearize_ty_params() and shapes\n" }, { "from": "gpt", "value": "// xfail-test\n\n// Tests that shapes respect linearize_ty_params().\n\ntag option<T> {\n none;\n some(T);\n}\n\ntype smallintmap<T> = @{mutable v: [mutable option<T>]};...
rust
chosen
[ { "from": "human", "value": "Add rust code for isogram case\n\nIt passed all test cases\n" }, { "from": "gpt", "value": "#![feature(ascii_ctype)]\n\npub fn check(words: &str) -> bool {\n let mut mask = 0u32;\n\n for c in words.chars() {\n if c.is_ascii_alphabetic() {\n le...
rust
chosen
[ { "from": "human", "value": "Add regression test for write_primval bug.\n" }, { "from": "gpt", "value": "// PrimVals in Miri are represented with 8 bytes (u64) and at the time of writing, the `-x`\n// will sign extend into the entire 8 bytes. Then, if you tried to write the `-x` into\n// somethi...
rust
chosen
[ { "from": "human", "value": "Add compile-fail test to assert HasDual is sealed\n" }, { "from": "gpt", "value": "extern crate session_types;\n\nuse session_types::HasDual;\n\nstruct CustomProto;\n\nimpl HasDual for CustomProto { //~ ERROR the trait bound `CustomProto: session_types::private::Seal...
rust
chosen
[ { "from": "system", "value": "Add an Rc reference cycle test.\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": "system", "value": "Add test to new branches\n" }, { "from": "human", "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": "system", "value": "Return of basic S3 tests.\n" }, { "from": "human", "value": "#![cfg(feature = \"s3\")]\n\nextern crate env_logger;\n#[macro_use]\nextern crate log;\nextern crate time;\n\n#[macro_use]\nextern crate rusoto;\n\nuse rusoto::{DefaultCredentialsProvider, Region};\nuse ru...
rust
chosen
[ { "from": "human", "value": "test: Implement a test for the Drop trait on a generic struct. a=test-only\n" }, { "from": "gpt", "value": "struct S<T> {\n x: T\n}\n\nimpl<T> S<T> : core::ops::Drop {\n fn finalize() {\n io::println(\"bye\");\n }\n}\n\nfn main() {\n let x = S { x:...
rust
chosen
[ { "from": "human", "value": "examples: Add example for storing file feature\n" }, { "from": "gpt", "value": "extern crate fruently;\nuse std::env;\nuse fruently::fluent::Fluent;\nuse fruently::retry_conf::RetryConf;\nuse std::collections::HashMap;\nuse fruently::forwardable::MsgpackForwardable;\...
rust
chosen
[ { "from": "human", "value": "Add concrete test for square array\n" }, { "from": "gpt", "value": "extern crate fitsio;\n\nuse fitsio::FitsFile;\n\n#[test]\nfn test_square_array() {\n let filename = \"../testdata/square_array.fits\";\n let mut f = FitsFile::open(filename).unwrap();\n let ...
rust
chosen
[ { "from": "human", "value": "Add compile-fail test for invalid cfg predicate in attribute\n\nRefs #31495\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/COPY...
rust
chosen
[ { "from": "human", "value": "Add an xfailed test for bogus vector addition of typarams\n" }, { "from": "gpt", "value": "// xfail-test\n// expected error: mismatched kinds\n\nresource r(i: @mutable int) {\n *i = *i + 1;\n}\n\nfn f<@T>(i: [T], j: [T]) {\n // Shouldn't be able to do this copy...
rust
chosen
[ { "from": "system", "value": "Fix a stack to use the new .to_c_str() api\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// Licensed under ...
rust
chosen
[ { "from": "human", "value": "Test that multiple wrappers created from a handle share a ref count\n" }, { "from": "gpt", "value": "/* Copyright 2015 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, ...
rust
chosen
[ { "from": "human", "value": "Add tests for checking for extraneous leading newlines (or lack thereof)\n\nCouldn't find a better place to put this (the \"valid\" and \"invalid\"\ntests are just for parser) so I made a new test module\n" }, { "from": "gpt", "value": "extern crate rustc_serialize;\...
rust
chosen
[ { "from": "human", "value": "Duplicate test for type conversion with unsigned int\n\nThis patch duplicates the test that was done with indexmap here with the\nnormal HashMap from std.\n\nSigned-off-by: Matthias Beyer <1d6e1cf70ec6f9ab28d3ea4b27a49a77654d370e@beyermatthias.de>\n" }, { "from": "gpt", ...
rust
chosen
[ { "from": "human", "value": "Add regression tests from fuzzing test cases.\n\nThis is the test case from frewsxcv's fuzzing work,\ngenerated by American Fuzzy Lop's rust support.\n\nhttps://github.com/mozilla/mp4parse-rust/issues/2\n" }, { "from": "gpt", "value": "// Regression tests from Americ...
rust
chosen
[ { "from": "human", "value": "Add a test for errors unifying an integer variable with a float variable\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/COPYRIG...
rust
chosen
[ { "from": "human", "value": "test: Add a test that function argument patterns take in the expected type. r=test-only\n" }, { "from": "gpt", "value": "fn main() {\n let f: fn((int,int)) = |(x, y)| {\n assert x == 1;\n assert y == 2;\n };\n f((1, 2));\n}\n\n" } ]
rust
chosen
[ { "from": "human", "value": "Add counting up with line clearing example\n" }, { "from": "gpt", "value": "use std::io::timer;\nuse std::io::stdio;\n\nfn main() {\n stdio::print(\"Loading...\");\n stdio::flush();\n timer::sleep(1000);\n for num in range(0, 1000) {\n stdio::print(\"\\r\\x1b[...
rust
chosen
[ { "from": "human", "value": "Add a regression test for use of unexported fully-qualified paths\n\nAn unexported foo.baz can't be resolved from inside foo when called as foo.baz\ninstead of just baz. This behavior may want to change eventually.\n" }, { "from": "gpt", "value": "// xfail-boot\n// e...
rust
chosen
[ { "from": "human", "value": "Add tests for ensuring docblock headings.\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n\n// @has foo/trait.Read.html\n// @has - '//h2' 'Trait examples'\n/// # Trait examples\npub trait Read {\n // @has - '//h5' 'Function examples'\n /// # Function...
rust
chosen
[ { "from": "human", "value": "Add piping code for Commands\n\nThis does piping properly, but it is not integrated with the rest of\nthe application.\n" }, { "from": "gpt", "value": "use std::process::{Stdio, Command, Child};\nuse std::os::unix::io::{FromRawFd, IntoRawFd};\n\npub fn pipe(commands:...
rust
chosen
[ { "from": "human", "value": "Add test for 'std' crate being public\n" }, { "from": "gpt", "value": "// The 'std' crates should always be implicitly public,\n// without having to pass any compiler arguments\n\n// run-pass\n\n#![feature(public_private_dependencies)]\n#![deny(external_private_depen...
rust
chosen
[ { "from": "human", "value": "Add test for const endianess conversion\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 Ap...
rust
chosen
[ { "from": "system", "value": "Update rustc-serialize import to new syntax\n" }, { "from": "human", "value": "#![feature(core)]\n#![feature(io)]\n#![feature(std_misc)]\n#![feature(step_by)]\n#![feature(test)]\n\nextern crate byteorder;\nextern crate flate2;\nextern crate nbt;\nextern crate \"rust...
rust
chosen
[ { "from": "human", "value": "Add Rust solutin for balanced brackets\n" }, { "from": "gpt", "value": "use std::collections::HashMap;\n\nfn balanced_brackets(s: &str) -> bool {\n // Use a vector as a stack\n let mut stack = Vec::new();\n\n let mut matches = HashMap::new();\n matches.insert(')'...
rust
chosen
[ { "from": "human", "value": "Make rust-la build with latest rust.\n" }, { "from": "gpt", "value": "// Copyright 2013 The Servo Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution.\n//\n// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or...
rust
chosen
[ { "from": "human", "value": "Add tests involving Rc, Arc, and Cell.\n" }, { "from": "gpt", "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:...
rust
chosen
[ { "from": "human", "value": "test: Add test that aux2bib runs\n\nThis just tests that aux2bib exists and runs. I couldn't find\ndocumentation on doing tests of binaries, but borrowed from what ripgrep\ndoes.\n\nThis test may break in the future if Cargo changes where binaries for\ntests are built.\n" }, ...
rust
chosen
[ { "from": "human", "value": "Add an example for counted flags.\n\nClose #56.\n" }, { "from": "gpt", "value": "extern crate serialize;\nextern crate docopt;\n\nuse docopt::Docopt;\n\n// This shows how to implement multiple levels of verbosity.\n//\n// When you have multiple patterns, I think the ...
rust
chosen
[ { "from": "human", "value": "Check that `chdir` fails for non-utf8 paths\n" }, { "from": "gpt", "value": "// compile-flags: -Zmiri-disable-isolation\n\nextern {\n pub fn chdir(dir: *const u8) -> i32;\n}\n\nfn main() {\n let path = vec![0xc3u8, 0x28, 0];\n // test that `chdir` errors wit...
rust
chosen
[ { "from": "human", "value": "Solve Salary with Bonus 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 let mut input_c = String::new();\n\n if let Err(_e) = io::stdin().read_line(&mut input_a){...
rust
chosen
[ { "from": "human", "value": "Add solution to problem 29\n" }, { "from": "gpt", "value": "#![feature(core)]\n#[macro_use] extern crate libeuler;\nextern crate num;\n\nuse num::traits::FromPrimitive;\nuse num::bigint::BigInt;\nuse num::pow;\n\nuse std::collections::HashSet;\n\n/// Consider all int...
rust
chosen
[ { "from": "human", "value": "Add rust code for allergies case\n\nI don't know how to exchange enum type and u32 type\n" }, { "from": "gpt", "value": "#[derive(Debug, Clone, PartialEq)]\npub enum Allergen {\n Eggs = 0x0000_0001,\n Peanuts = 0x0000_0002,\n Shellfish = 0x0000_0004,\n St...
rust
chosen
[ { "from": "human", "value": "test(Rust): Add test for sizeof structs and enums\n" }, { "from": "gpt", "value": "//! Print sizes of structs and enums\n//!\n//! Run with `cargo test sizes -- --nocapture`\n//! to get the printed output.\n\nuse stencila_schema::*;\n\nmacro_rules! sizeof {\n ($typ...
rust
chosen
[ { "from": "human", "value": "Add test extracted from rand, checking that StorageDead kills loans\n\nLike \"call-kills-loans\", Polonius didn't know about some `killed` facts.\n" }, { "from": "gpt", "value": "// Whenever a `StorageDead` MIR statement destroys a value `x`,\n// we should kill all l...
rust
chosen
[ { "from": "human", "value": "Add skeleton code for HashJoinExec.\n" }, { "from": "gpt", "value": "use common::types::Ty;\nuse driver::DriverContext;\nuse super::{Executor, ExecutorFactory};\n\npub struct HashJoinExecFactory \n{\n\ttypes: Vec<Ty>\n}\n\nimpl HashJoinExecFactory\n{\n\tpub fn new(lf...
rust
chosen
[ { "from": "human", "value": "Add missing file from previous commit." }, { "from": "gpt", "value": "use hyper::net::Openssl;\nuse openssl::crypto::pkey::PKey;\nuse openssl::ssl::{SslContext, SslMethod, SSL_VERIFY_NONE};\nuse openssl::ssl::error::SslError;\nuse openssl::x509::X509;\nuse std::io::C...
rust
chosen
[ { "from": "human", "value": "Prepare code for a flat_map test\n" }, { "from": "gpt", "value": "#[macro_use]\nextern crate nom;\n\nuse nom::{IResult, Needed, alphanumeric, is_alphanumeric};\n\nnamed!(certain_length<&[u8], &[u8]>, take!(10));\n\nnamed!(value<&[u8], &[u8]>,\n take_while!(is_a...
rust
chosen
[ { "from": "human", "value": "Add enum representing OSC types\n" }, { "from": "gpt", "value": "// see OSC Type Tag String: http://opensoundcontrol.org/spec-1_0\n// padding: zero bytes (n*4)\npub enum OscType {\n OscInt(i32),\n OscFloat(f32),\n OscString(String), // padding\n OscBlob(V...
rust
chosen
[ { "from": "human", "value": "Introduce a testcase for conditional compilation via attributes\n\nIssue #489\n" }, { "from": "gpt", "value": "// xfail-stage0\n// xfail-stage1\n// xfail-stage2\n\n// Since the bogus configuration isn't defined main will just be\n// parsed, but nothing further will b...
rust
chosen
[ { "from": "human", "value": "Add rust code for rotational-cipher\n\nIt passed all testcases\n" }, { "from": "gpt", "value": "#![feature(ascii_ctype)]\nuse std::ascii::AsciiExt;\n\npub fn rotate(text: &str, key: usize) -> String {\n text.chars()\n .map(|x| match x {\n _ if x....
rust
chosen
[ { "from": "human", "value": "rustdoc: Add test for tuple rendering\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 Apac...
rust
chosen
[ { "from": "human", "value": "chore(Kernels): Add a \"mini-CLI\" for development purposes\n" }, { "from": "gpt", "value": "//! Mini CLI for testing this crate at the command line without compiling the whole `stencila` binary.\n//! Run using `cargo run --all-features` in this crate (`--all-feature...
rust
chosen
[ { "from": "system", "value": "Fix test that was using rust_task_allow_kill incorrectly\n" }, { "from": "human", "value": "/*\n A reduced test case for Issue #506, provided by Rob Arnold.\n*/\n\nuse std;\nimport task;\n\n#[abi = \"cdecl\"]\nextern mod rustrt {\n fn rust_task_allow_kill();\n}\...
rust
chosen
[ { "from": "human", "value": "Add a benchmark for the Negamax implementation.\n" }, { "from": "gpt", "value": "#![feature(test)]\nextern crate minimax;\nextern crate test;\nuse test::Bencher;\nuse minimax::*;\n\n#[derive(Clone)]\npub struct Board;\n\n#[derive(Copy, Clone)]\npub struct Place;\n\np...
rust
chosen
[ { "from": "human", "value": "Add test for new DOM for empty impls\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n\n// @has foo/struct.Foo.html\n// @has - '//div[@id=\"synthetic-implementations-list\"]/h3[@id=\"impl-Send\"]' 'impl Send for Foo'\npub struct Foo;\n\npub trait EmptyTrait...
rust
chosen
[ { "from": "human", "value": "Add a test for std::any::type_name() as a const fn\n\nThis is a modified version of the test I added previously. The difference is this version implements a wrapper around std::any::type_name versus core::intrinsics::type_name, in order to show that it works as desired / intende...
rust
chosen
[ { "from": "human", "value": "Add test for trait toggle location\n" }, { "from": "gpt", "value": "#![crate_name = \"foo\"]\n\n// @has foo/trait.Foo.html\n// @has - '//details[@class=\"rustdoc-toggle\"]//code' 'bar'\npub trait Foo {\n fn bar() -> ();\n}\n" } ]
rust
chosen
[ { "from": "human", "value": "Add a benchmark test for edit_distance function.\n" }, { "from": "gpt", "value": "#![feature(test)]\n\nextern crate test;\nextern crate bloodhound;\n\nuse test::Bencher;\nuse std::path::PathBuf;\nuse bloodhound::matching::find;\n\n#[bench]\nfn bench_edit_distance(b: ...
rust
chosen
[ { "from": "human", "value": "Add rust code for luhn-from case\n\nIt passed all testcases\n" }, { "from": "gpt", "value": "pub struct Luhn {\n result: Option<String>,\n}\n\nfn is_valid(id: &str) -> bool {\n if id.len() < 2 {\n return false;\n }\n\n let mut index: u32 = 0;\n ...
rust
chosen
[ { "from": "human", "value": "Add a very basic example\n" }, { "from": "gpt", "value": "extern crate ansi_term;\nuse ansi_term::Colour::*;\n\nfn main() {\n println!(\"{}\", Black.paint(\"Black\"));\n println!(\"{}\", Red.paint(\"Red\"));\n println!(\"{}\", Green.paint(\"Green\"));\n p...
rust
chosen
[ { "from": "human", "value": "Add inline const macro test\n" }, { "from": "gpt", "value": "// run-pass\n\n#![allow(incomplete_features)]\n#![feature(inline_const)]\nmacro_rules! do_const_block{\n ($val:block) => { const $val }\n}\n\nfn main() {\n let s = do_const_block!({ 22 });\n assert...
rust
chosen
[ { "from": "human", "value": "Add test to prevent regression\n" }, { "from": "gpt", "value": "// check-pass\n//\n// Regression test for issue #86082\n//\n// Checks that option_env! does not panic on receiving an invalid\n// environment variable name.\n\nfn main() {\n option_env!(\"\\0=\");\n}\...
rust
chosen
[ { "from": "system", "value": "Remove irrelevant parts of test\n" }, { "from": "human", "value": "// -*- rust -*-\n// xfail-test\n// error-pattern:Unsatisfied precondition\n\ntag list { cons(int, @list); nil; }\n\ntype bubu = {x: int, y: int};\n\npure fn less_than(x: int, y: int) -> bool { ret x ...
rust
chosen
[ { "from": "human", "value": "Add test for braced-macro followed by `.` or `?`.\n" }, { "from": "gpt", "value": "// check-pass\n\nuse std::io::Write;\n\nfn main() -> Result<(), std::io::Error> {\n vec! { 1, 2, 3 }.len();\n write! { vec![], \"\" }?;\n Ok(())\n}\n" } ]
rust
chosen
[ { "from": "human", "value": "Test nested `proc` can access outer owned data\n\nFixes #10682\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/...
rust
chosen
[ { "from": "human", "value": "Add a test for escaping LLVMisms in inline asm\n\nWe escape certain LLVM-specific features when passing the inline\nassembly string to the LLVM. Until now, however, there was no test\nmaking sure this behaviour stays intact. This commit adds such a test!\n" }, { "from": ...
rust
chosen