conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Remove warnings from test project\n\nAmusingly enough I need to add some more dead code to a failing test to\nget rid of the unused and unnecessarily `mut` warnings.\n" }, { "from": "human", "value": "extern crate basiccms;\n\n#[cfg(test)]\nmod tests {\n\n use ba...
rust
chosen
[ { "from": "system", "value": "Read at most `buffer_size` events\n" }, { "from": "human", "value": "extern crate portmidi as pm;\n\nextern crate rustc_serialize;\nextern crate docopt;\n\nconst USAGE: &'static str = r#\"\nportmidi-rs: monitor-device example\n\nUsage:\n monitor-device <id>\n\nOp...
rust
chosen
[ { "from": "system", "value": "Add unreachable() fn, also nitpicking\n" }, { "from": "human", "value": "\n\nfn id<@T>(x: T) -> T { ret x; }\n\n\n/* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment\n * the constraint once fixed. */\ntype rational = {num: int, den: int};\n\n\n...
rust
chosen
[ { "from": "system", "value": "Add color field to Desc component\n" }, { "from": "human", "value": "/// Entity name and appearance.\n#[deriving(Clone, Show, Encodable, Decodable)]\npub struct Desc {\n pub name: String,\n pub icon: uint,\n}\n\nimpl Desc {\n pub fn new(name: String, icon: ...
rust
chosen
[ { "from": "system", "value": "Update example to conform to new message arg behavior\n" }, { "from": "human", "value": "#[macro_use]\nextern crate serde_derive;\nextern crate serde;\nextern crate serde_bytes;\nextern crate serde_osc;\n\nuse serde_bytes::ByteBuf;\nuse serde_osc::{de, ser};\n\n/// ...
rust
chosen
[ { "from": "system", "value": "Change deny attribute to warn in ruma-client-api\n" }, { "from": "human", "value": "//! Crate ruma_client_api contains serializable types for the requests and responses for each\n//! endpoint in the [Matrix](https://matrix.org/) client API specification. These types...
rust
chosen
[ { "from": "system", "value": "Fix 'no information log' bug\n" }, { "from": "human", "value": "//! Helper functions for dealing with shaders.\n\n// External crates.\nuse gl;\nuse gl::types::{\n GLchar,\n GLenum,\n GLint,\n GLuint,\n};\n\nuse std::ptr;\n\n/// Compiles a shader.\n///\n/...
rust
chosen
[ { "from": "system", "value": "Remove unnecessary feature from instruction reference documentation generation code\n" }, { "from": "human", "value": "#![feature(proc_macro_hygiene)]\n\nuse std::io::{self, Write};\n\nfn main() {\n let mut args = std::env::args();\n args.next().unwrap();\n\n ...
rust
chosen
[ { "from": "system", "value": "Use bigint when computing binomial coefficients\n" }, { "from": "human", "value": "// http://rosettacode.org/wiki/Evaluate_binomial_coefficients\n\nfn binomial(n: uint, mut k: uint) -> u64 {\n // Since binomial(n, k) = binomial(n, n - k), we might as well use\n ...
rust
chosen
[ { "from": "system", "value": "Use macros for creating ruby methods\n" }, { "from": "human", "value": "#![no_std]\nextern crate ruru;\n\nuse ruru::VM;\nuse ruru::Hash;\nuse ruru::Fixnum;\nuse ruru::Class;\nuse ruru::types::Argc;\nuse ruru::AnyObject;\n\n#[no_mangle]\npub extern fn pow_3(argc: Arg...
rust
chosen
[ { "from": "system", "value": "Change return code for configuration error\n" }, { "from": "human", "value": "use ghclient::GithubClient;\nuse std;\nuse std::env;\nuse std::path::Path;\nuse std::string::String;\nuse structs::Config;\n\nlazy_static! {\n static ref DEFAULT_CONF_PATH_STR:String = ...
rust
chosen
[ { "from": "system", "value": "Set lld flavor for MSVC to link.exe\n" }, { "from": "human", "value": "use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};\nuse std::default::Default;\n\npub fn opts() -> TargetOptions {\n let mut args = LinkArgs::new();\n args.insert(LinkerFlavor::Msvc,...
rust
chosen
[ { "from": "system", "value": "Add with-deprecated and doc hidden attributes\n" }, { "from": "human", "value": "//! Provides types and functions related to working with PostgreSQL\n//!\n//! Much of this module is re-exported from database agnostic locations.\n//! However, if you are writing code ...
rust
chosen
[ { "from": "system", "value": "Add regression test for macro expansion\n" }, { "from": "human", "value": "// run-rustfix\n\n#![warn(clippy::toplevel_ref_arg)]\n#![allow(unused)]\n\nfn main() {\n // Closures should not warn\n let y = |ref x| println!(\"{:?}\", x);\n y(1u8);\n\n let ref...
rust
chosen
[ { "from": "system", "value": "Add a unit test module\n\nDoctests seem to suppress warnings (note PR #1 was about the \"unused type\" warning)\n\nSigned-off-by: NODA, Kai <a445972a03eaa731f8b4469e4f864a9a57c01ed3@gmail.com>\n" }, { "from": "human", "value": "//! A library implementation of so-cal...
rust
chosen
[ { "from": "system", "value": "Update serde_derive_internals to tool attrs\n" }, { "from": "human", "value": "#![doc(html_root_url = \"https://docs.rs/serde_derive_internals/0.25.0\")]\n#![allow(unknown_lints, bare_trait_objects)]\n#![cfg_attr(feature = \"cargo-clippy\", allow(renamed_and_removed...
rust
chosen
[ { "from": "system", "value": "Use `into_inner` instead of `unwrap`.\n" }, { "from": "human", "value": "use nalgebra::{Isometry3, Matrix4, Perspective3, Point3, Real, Scalar, Vector3};\n\npub struct Camera<T>\nwhere\n T: Real + Scalar,\n{\n projection: Perspective3<T>,\n view: Isometry3<...
rust
chosen
[ { "from": "system", "value": "Improve solution for Scrabble Score\n" }, { "from": "human", "value": "pub fn score(word: &str) -> u32 {\n let mut score = 0;\n\n for c in word.chars() {\n score += match c.to_lowercase().to_string().as_ref() {\n \"a\" | \"e\" | \"i\" | \"o\"...
rust
chosen
[ { "from": "system", "value": "Redefine Multiboot info struct in an easier way. Because we do not know what tags will be there at startup, we need to use the tag iterator to search for the tags by their tag type as we need them.\n" }, { "from": "human", "value": "use bios_boot_device::BIOSBootDev...
rust
chosen
[ { "from": "system", "value": "testsuite: Update error message, unbreak build\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 un...
rust
chosen
[ { "from": "system", "value": "Implement n = 1, n = 2 special cases\n" }, { "from": "human", "value": "//! Quicksort algorithm.\n//!\n//! The `efficient` module contains the efficient sorting algorithm \"Quicksort\".\n//!\n//! Source: https://en.wikipedia.org/wiki/Quicksort\n\n\n/// Quicksort\n//...
rust
chosen
[ { "from": "system", "value": "format: Drop the easy Buffered implementation for Cursor\n" }, { "from": "human", "value": "mod accreader;\n\npub use self::accreader::AccReader;\n\nuse std::io::{BufRead, Seek, Cursor};\n\npub trait Buffered: BufRead + Seek {\n fn data(&self) -> &[u8];\n}\n\nimp...
rust
chosen
[ { "from": "system", "value": "Update IO references to use old_io module.\n" }, { "from": "human", "value": "use std::io::{File, Open, ReadWrite};\nuse std::io::IoResult;\nuse super::GapBuffer;\nuse super::gap_buffer;\nuse super::Position;\nuse super::Range;\n\npub struct Buffer {\n data: GapB...
rust
chosen
[ { "from": "system", "value": "[Fix] Add option \"indeed\" to cron contents\n" }, { "from": "human", "value": "use error::{CliError, Usage, UsageKind};\nuse super::Command;\n\nuse lib::setting::{Config, ConfigKey, Cron};\n\n#[derive(Debug)]\npub struct Start;\n\nimpl Command for Start {\n fn u...
rust
chosen
[ { "from": "system", "value": "Fix another Eq missing case.\n" }, { "from": "human", "value": "import option;\n\nenum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }\n\ntype config = {\n // The library paths required for running the compiler\n compile_lib_path: ~str,\...
rust
chosen
[ { "from": "system", "value": "Update for removal of std::error::FromError\n" }, { "from": "human", "value": "#![feature(plugin, str_char, slice_patterns, convert, core)]\n#![plugin(regex_macros)]\nextern crate regex;\nextern crate chrono;\n#[macro_use]\nextern crate log as l;\n\npub mod log;\npu...
rust
chosen
[ { "from": "system", "value": "Add test for filling tensor! macro\n" }, { "from": "human", "value": "use numeric::Tensor;\n\n#[test]\nfn tensor_1d() {\n let x = Tensor::new(vec![1, 2, 3, 4, 5, 6]);\n assert!(x == tensor![1, 2, 3, 4, 5, 6]);\n assert!(x == tensor![1, 2, 3, 4, 5, 6,]);\n}\...
rust
chosen
[ { "from": "system", "value": "Use iterator, not indices, in mods_to_lua\n\nMore likely to be optimized by the compiler\n" }, { "from": "human", "value": "//! Utilities to talk to Lua\n\nuse rlua::{self, Table};\nuse rustwlc::*;\n\nconst MOD_NAMES: [&str; 8] = [\"Shift\", \"Caps\", \"Control\", \...
rust
chosen
[ { "from": "system", "value": "Add basic loop to `Harness`.\n" }, { "from": "human", "value": "use event::Reactor;\nuse render::{Context, GlutinContext, MetaContext};\n\npub struct Harness<A, C>\n where A: Application,\n C: MetaContext\n{\n application: A,\n context: Context<C>,...
rust
chosen
[ { "from": "system", "value": "Add function to get closest word for specified word in words array\n" }, { "from": "human", "value": "pub mod sequencematcher;\npub mod differ;\nmod utils;" }, { "from": "gpt", "value": "pub mod sequencematcher;\npub mod differ;\nmod utils;\n\n\nuse sequ...
rust
chosen
[ { "from": "system", "value": "Mark the crate as experimental.\n" }, { "from": "human", "value": "#![crate_name = \"quickcheck\"]\n#![crate_type = \"lib\"]\n#![license = \"UNLICENSE\"]\n#![doc(html_root_url = \"http://burntsushi.net/rustdoc/quickcheck\")]\n\n//! This crate is a port of\n//! [Hask...
rust
chosen
[ { "from": "system", "value": "Add (But not yet implement) the Minecraft protocol version declaration\n" }, { "from": "human", "value": "//! Entry module for the Netherrack project\n\n// We'll be using serialization a lot\nextern crate rustc_serialize;\n\n// Enable logging and use of logging macr...
rust
chosen
[ { "from": "system", "value": "Disable ui tests on emscripten\n\nThese hit a strange error in our Emscripten builder in Travis as well as\nlocally through cargo web:\n\n ERROR: failed to execute cargo: Resource temporarily unavailable (os error 11)\n" }, { "from": "human", "value": "#[rustc::a...
rust
chosen
[ { "from": "system", "value": "Fix sample `clone_dyn_trivial_sample`, add condition\n" }, { "from": "human", "value": "#[ allow( unused_imports ) ]\nuse clone_dyn::clone_dyn;\n\nfn main()\n{\n\n #[ clone_dyn ]\n trait Trait1\n {\n }\n\n let vec = Vec::< Box< dyn Trait1 > >::new();\n let _ve...
rust
chosen
[ { "from": "system", "value": "Remove reexport subframe module items\n" }, { "from": "human", "value": "//! An implementation of [FLAC](https://xiph.org/flac), free lossless audio\n//! codec, written in Rust.\n//!\n//! # Examples\n//!\n//! Basic decoding from a file.\n//!\n//! ```\n//! match flac...
rust
chosen
[ { "from": "system", "value": "Make the error module public\n" }, { "from": "human", "value": "//! A simple library for reading and writing Riegl .sdc files.\n//!\n//! .sdc files are simple binary tables of discrete-return LiDAR data.\n\nextern crate byteorder;\n\nmod error;\npub mod file;\npub m...
rust
chosen
[ { "from": "system", "value": "Include C++ dependencies in license metadata\n" }, { "from": "human", "value": "//! Detect the language of a string using the [cld2 library][cld2] from the\n//! Chromium project.\n//!\n//! ```\n//! use cld2::{detect_language, Format, Reliable, Lang};\n//!\n//! let t...
rust
chosen
[ { "from": "system", "value": "Disable unstable warnings for now\n" }, { "from": "human", "value": "#![feature(slicing_syntax)]\n#![crate_type = \"lib\"]\n#![crate_name = \"suruga\"]\n#![allow(missing_copy_implementations)]\n\n#[macro_use]\nextern crate log;\n\npub use tls::Tls;\npub use client::...
rust
chosen
[ { "from": "system", "value": "Update the tests for Rust 1.0\n" }, { "from": "human", "value": "#![feature(plugin)]\n\n#![allow(unstable)] // TODO: remove this\n\n//! Making sure that no warning is generated by code from generate_gl_bindings!\n#![deny(warnings)]\n\nextern crate libc;\n\ninclu...
rust
chosen
[ { "from": "system", "value": "refactor(build): Update clap usage for new crate requirements\n" }, { "from": "human", "value": "use clap::{FromArgMatches, IntoApp};\n\nuse casile::cli::{Cli, Subcommand};\nuse casile::config::CONF;\nuse casile::{make, setup, status};\nuse casile::{Result, VERSION}...
rust
chosen
[ { "from": "system", "value": "Check agains `addr` field of source `msg`\n" }, { "from": "human", "value": "extern crate rosc;\n\nuse rosc::{encoder, decoder, errors};\nuse rosc::errors::OscError;\nuse rosc::types::{Result, OscMessage, OscPacket};\n\n#[test]\nfn test_encode_message_wo_args() {\n ...
rust
chosen
[ { "from": "system", "value": "Change `_index` variable to something clearer\n" }, { "from": "human", "value": "use std::io::{self, Write};\nuse std::fs::File;\n\nuse flac::stream::StreamReader;\nuse flac::metadata::{self, Picture};\n\npub const USAGE: &'static str = \"\nUsage: metadata picture [...
rust
chosen
[ { "from": "system", "value": "Add features for when testing\n" }, { "from": "human", "value": "#![crate_name = \"rboy\"]\n#![crate_type = \"lib\" ]\n\n#![feature(io, core, path)]\n\n#[macro_use]\nextern crate log;\n\nextern crate time;\n\n#[cfg(test)]\nextern crate test;\n\npub use keypad::Keypa...
rust
chosen
[ { "from": "system", "value": "Reformat and rename method testing tests for better organization\n" }, { "from": "human", "value": "#[macro_use]\nextern crate askama;\n\nuse askama::Template;\n\n#[derive(Template)]\n#[template(source = \"{{ self.get_s() }}\", ext = \"txt\")]\nstruct MethodTemplate...
rust
chosen
[ { "from": "system", "value": "Use `allow_internal_unstable` in rustc itself\n" }, { "from": "human", "value": "/// A simple static assertion macro. The first argument should be a unique\n/// ALL_CAPS identifier that describes the condition.\n#[macro_export]\n#[allow_internal_unstable]\nmacro_rul...
rust
chosen
[ { "from": "system", "value": "Fix shift-overflow in very old run-pass 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// Licensed und...
rust
chosen
[ { "from": "system", "value": "Remove dead argument code for replacement\n" }, { "from": "human", "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 let brief ...
rust
chosen
[ { "from": "system", "value": "Remove deprecated mpv option usage.\n" }, { "from": "human", "value": "extern crate gtk;\n\nuse gtk::prelude::*;\n\nuse std::error::Error;\nuse std::io::prelude::*;\nuse std::fs::File;\nuse std::path::Path;\nuse std::env;\n\nfn main() {\n gtk::init().expect(\"Fai...
rust
chosen
[ { "from": "system", "value": "Add support for a few base types\n\n- small_integer\n- integer\n- atom\n" }, { "from": "human", "value": "#[macro_use]\nextern crate nom;\n\nuse std::io;\nuse std::io::Read;\n\nstatic BERT_MAGIC_NUMBER: u8 = 131;\n\n#[derive(Debug)]\nenum BertTerm {\n Int(i32),\n...
rust
chosen
[ { "from": "system", "value": "Add proper error handling on wrong numbers\n" }, { "from": "human", "value": "extern crate rand;\n\nuse std::io;\nuse std::cmp::Ordering;\nuse rand::Rng;\n\nfn main() {\n println!(\"Hello to the guessing game!\");\n\n\n let std_in = io::stdin();\n\n let num...
rust
chosen
[ { "from": "system", "value": "Add initial implementation of CLI\n" }, { "from": "human", "value": "fn main() {\n println!(\"Hello, world!\");\n}\n" }, { "from": "gpt", "value": "extern crate getopts;\n\nuse getopts::Options;\n\nuse std::env;\nuse std::fs::File;\nuse std::path::Pat...
rust
chosen
[ { "from": "system", "value": "Print help message when given no arguments.\n" }, { "from": "human", "value": "extern crate clap;\n\nuse clap::{Arg, App};\nuse std::fs::File;\nuse std::io;\n\nfn main() {\n let matches = App::new(env!(\"CARGO_PKG_NAME\"))\n .version(env!(\"CARGO_PKG_VERSI...
rust
chosen
[ { "from": "system", "value": "Exit when ctrl-d is entered\n\nhowever, empty lines (e.g. just newline) do not terminate\n" }, { "from": "human", "value": "use std::io;\nuse std::io::prelude::*;\nuse std::collections::HashMap;\npub mod parser;\n\nfn evaluate(input: &str, env: &mut HashMap<String, ...
rust
chosen
[ { "from": "system", "value": "Add a TCP read timeout to network connection\n" }, { "from": "human", "value": "use std::io::{BufReader, Write};\nuse std::net::{TcpListener, TcpStream};\nuse std::thread;\n\nuse birch::network::NetworkConnection;\nuse birch::socket::IRCReader;\n\nfn main() {\n /...
rust
chosen
[ { "from": "system", "value": "Reimplement IsInDiary for StoreId with StoreId::is_in_collection()\n" }, { "from": "human", "value": "use libimagstore::store::Entry;\nuse libimagstore::storeid::StoreId;\n\npub trait IsInDiary {\n\n fn is_in_diary(&self, name: &str) -> bool;\n\n}\n\nimpl IsInDia...
rust
chosen
[ { "from": "system", "value": "Add tests from rustfmt::skip test file\n" }, { "from": "human", "value": "#![feature(tool_lints)]\n\n#![warn(clippy::deprecated_cfg_attr)]\n\n// This doesn't get linted, see known problems\n#![cfg_attr(rustfmt, rustfmt_skip)]\n\n#[cfg_attr(rustfmt, rustfmt_skip)]\nf...
rust
chosen
[ { "from": "system", "value": "Change default port to 8080\n\nPort 80 as a default requires you to run `sudo`. This changes the\ndefault port to 8080 which doesn't require sudo privileges to run.\n" }, { "from": "human", "value": "extern crate iron;\nextern crate staticfile;\n\nuse iron::Iron;\n\...
rust
chosen
[ { "from": "system", "value": "Initialize vm on intepreter start\n" }, { "from": "human", "value": "mod vm;\nmod command;\nmod parse;\n\nuse std::io::Write;\n\nfn main() {\n loop {\n print!(\"{}\", \"bf> \");\n std::io::stdout().flush().unwrap();\n\n let mut line = String:...
rust
chosen
[ { "from": "system", "value": "Disable rustfmt on a line we don't want changed\n" }, { "from": "human", "value": "use std::io;\nuse std::io::prelude::*;\n\npub fn parse_update_count(tag: String) -> u64 {\n tag.split(' ').last().unwrap().parse().unwrap_or(0)\n}\n\npub fn read_all<R: Read>(r: &m...
rust
chosen
[ { "from": "system", "value": "x86_common: Add initialization of the console\n" }, { "from": "human", "value": "use ::xen::StartInfo;\n\npub mod defs;\npub mod barrier;\npub mod memory;\n\nextern {\n // Start info is not present on all architecture, this is why this\n // was made a global v...
rust
chosen
[ { "from": "system", "value": "Make Opts no longer a record\n" }, { "from": "human", "value": "//! Configuration options for a single run of the servo application. Created\n//! from command line arguments.\n\npub type Opts = {\n urls: ~[~str],\n render_mode: RenderMode\n};\n\npub enum Rende...
rust
chosen
[ { "from": "system", "value": "Use spin::Once to initialize CPU count\n" }, { "from": "human", "value": "use vmx;\nuse collections::vec::Vec;\nuse core::sync::atomic::{ATOMIC_U16_INIT, AtomicU16, Ordering};\n\n\nstatic CPU_COUNT: AtomicU16 = ATOMIC_U16_INIT;\nstatic CPU_ASSIGNMENT: AtomicU16 = AT...
rust
chosen
[ { "from": "system", "value": "Fix format trait errors (breaking change)\n" }, { "from": "human", "value": "fn _12_1(){\n println!(\"guide 12-1\");\n\n let a = [1i, 2i, 3i];\n let mut m = [2i, 3i, 4i];\n\n let b = [0i, ..20]; // shorthand for array of 20 elements all initialized to 0\...
rust
chosen
[ { "from": "system", "value": "Fix use of the new function signatures\n" }, { "from": "human", "value": "#![feature(plugin)]\n#![plugin(rustlex)]\n#[allow(plugin_as_library)]\nextern crate rustlex;\n#[macro_use] extern crate log;\nextern crate time;\nextern crate term;\n\npub mod frontend;\npub m...
rust
chosen
[ { "from": "system", "value": "Stop and think and make it compile first\n" }, { "from": "human", "value": "// The shift characters are stored as nulls, as the conversion code doesn't\n// care what value they have. WRU? maps to ASCII ENQ (\\x05), I think.\nconst Ita2Letters = b\"\\0E\\nA SIU\\rDR...
rust
chosen
[ { "from": "system", "value": "Hide modules from the public API, only the re-exports should be used\n" }, { "from": "human", "value": "pub mod liblz4;\npub mod decoder;\npub mod encoder;\n\npub use decoder::Decoder;\npub use encoder::Encoder;\npub use encoder::EncoderBuilder;\npub use liblz4::Blo...
rust
chosen
[ { "from": "system", "value": "Verify that IcedError is Send + Sync\n" }, { "from": "human", "value": "// SPDX-License-Identifier: MIT\n// Copyright (C) 2018-present iced project and contributors\n\nuse alloc::borrow::Cow;\nuse alloc::string::String;\nuse core::fmt;\n#[cfg(feature = \"std\")]\nus...
rust
chosen
[ { "from": "system", "value": "Correct Twelve Days of Christmas Implementation\n\n- The lyrics given on the required page (http://www.lyricsmode.com/lyrics/c/christmas_carols/the_twelve_days_of_christmas.html) make this task much easier than you'd expect\r\n- I've also updated the implementation on the offic...
rust
chosen
[ { "from": "system", "value": "Fix clippy: Derive Eq as well\n\nSigned-off-by: Matthias Beyer <1d6e1cf70ec6f9ab28d3ea4b27a49a77654d370e@beyermatthias.de>\n" }, { "from": "human", "value": "use config::Config;\n#[derive(Debug, Default, serde_derive::Deserialize, PartialEq)]\nstruct AppConfig {\n ...
rust
chosen
[ { "from": "system", "value": "roman-numerals: Use `iter` instead of `into_iter` when not moving\n\nClippy suggested\nhttps://travis-ci.org/exercism/rust/builds/456432005\nerror: this .into_iter() call is equivalent to .iter() and will not move the array\n = help: for further information visit https://rust...
rust
chosen
[ { "from": "system", "value": "Check if best move in transposition table is valid\n" }, { "from": "human", "value": "use game::{Position, Move, ZobristHash, NumPlies};\n\nuse negamax::Bound;\n\n#[derive(Clone, Debug)]\npub struct Data {\n pub hash: ZobristHash,\n pub depth: NumPlies,\n p...
rust
chosen
[ { "from": "system", "value": "Update to use new for loop protocol, and fix for new `as` binding rules\n" }, { "from": "human", "value": "// Copyright 2013 The noise-rs developers. For a full listing of the authors,\n// refer to the AUTHORS file at the top-level directory of this distribution.\n/...
rust
chosen
[ { "from": "system", "value": "Make idiomatic the negemax benchmark's move generation function.\n" }, { "from": "human", "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)]\npu...
rust
chosen
[ { "from": "system", "value": "Implement RNA Transcription using FromIterator\n" }, { "from": "human", "value": "#[derive(PartialEq, Debug)]\npub struct RibonucleicAcid(String);\n\nimpl RibonucleicAcid {\n pub fn new(rna: &str) -> RibonucleicAcid {\n RibonucleicAcid(rna.into())\n }\n...
rust
chosen
[ { "from": "system", "value": "Add a note about the similarity to std::process::ExitStatus\n" }, { "from": "human", "value": "use std::process::Command;\n\n\npub struct Output {\n pub status: i32,\n pub stdout: String,\n pub stderr: String,\n}\n\n\n/// Run an AppleScript.\n///\n/// * `script`:...
rust
chosen
[ { "from": "system", "value": "Make imageflow_helpers run tests under system alloc\n" }, { "from": "human", "value": "#[macro_use]\nextern crate lazy_static;\n\nextern crate reqwest;\nextern crate hyper_native_tls;\nextern crate regex;\nextern crate hyper;\nextern crate blake2_rfc;\nextern crate ...
rust
chosen
[ { "from": "system", "value": "Revert \"enable only I/O reactor for async operations\"\n\nThis reverts commit 0b759a47339845cf5dea2097d3c0295bbdfc03c6.\n" }, { "from": "human", "value": "use lazy_static::lazy_static;\nuse std::future::Future;\nuse std::sync::Mutex;\nuse tokio::runtime::{Builder, ...
rust
chosen
[ { "from": "system", "value": "Make ByteConsumer own its reader\n\nThis is in preparation for making pq multi-threaded; the trait `Read`\nis not `Send` and so with the previous declaration (read: &'a mut\nRead) ByteConsumer was _not_ Send and could not be moved into a\nclosure, i.e., with thread::spawn.\n\nT...
rust
chosen
[ { "from": "system", "value": "Add actor + actor ref\n" }, { "from": "human", "value": "extern crate rand;\n\nuse std::sync::mpsc::{Sender, Receiver};\nuse std::sync::mpsc;\nuse std::{thread, time};\nuse rand::Rng;\n\nstatic NTHREADS: i32 = 64;\n\nfn main() {\n // Channels have two endpoints: ...
rust
chosen
[ { "from": "system", "value": "Remove return to satisfy clippy\n" }, { "from": "human", "value": "#[derive(Debug)]\npub enum CalculatorInput {\n Add,\n Subtract,\n Multiply,\n Divide,\n Value(i32),\n}\n\npub fn evaluate(inputs: &[CalculatorInput]) -> Option<i32> {\n let mut oper...
rust
chosen
[ { "from": "system", "value": "Use HashMap in JsObj instead of BTreeMap\n" }, { "from": "human", "value": "use std::collections::btree_map::BTreeMap;\nuse js_types::js_type::{JsType, JsThing};\n\npub struct JsObj {\n proto: Option<Box<JsObj>>,\n dict: BTreeMap<JsType, JsType>,\n}\n\nimpl Js...
rust
chosen
[ { "from": "system", "value": "Print log level for info messages\n\nSigned-off-by: Kaustav Das Modak <ba1ce5b1e09413a89404909d8d270942c5dadd14@yahoo.co.in>\n" }, { "from": "human", "value": "//! Console logger\n\nuse log::*;\n\n/// Logs to console\npub struct CLILogger;\n\nimpl CLILogger {\n p...
rust
chosen
[ { "from": "system", "value": "Check if stdin is from a tty\n" }, { "from": "human", "value": "#[test]\nfn it_works() {\n}\n" }, { "from": "gpt", "value": "#![feature(libc)]\nextern crate libc;\n\npub fn readline() -> Option<String> {\n // Buffer to hold readline input\n let buf...
rust
chosen
[ { "from": "system", "value": "Fix the procedural macro hygiene stuff.\n" }, { "from": "human", "value": "#![feature(proc_macro_non_items)]\n\npub mod app;\npub mod time;\npub mod render;\n" }, { "from": "gpt", "value": "#![feature(proc_macro_hygiene)]\n\npub mod app;\npub mod time;\n...
rust
chosen
[ { "from": "system", "value": "identity-service-api: Add crate-level docs and warn on missing docs\n" }, { "from": "human", "value": "#![doc(html_favicon_url = \"https://www.ruma.io/favicon.ico\")]\n#![doc(html_logo_url = \"https://www.ruma.io/images/logo.png\")]\n\npub mod authentication;\npub m...
rust
chosen
[ { "from": "system", "value": "Add `i` suffix to cfail test so it works after suffix inference\n" }, { "from": "human", "value": "fn f(f: fn@(int) -> bool) -> bool { f(10) }\n\nfn main() {\n assert do f() { |i| i == 10 } == 10; //! ERROR: expected `bool` but found `int`\n}\n" }, { "fro...
rust
chosen
[ { "from": "system", "value": "Make layout SizeOverflow test trigger on i686.\n" }, { "from": "human", "value": "fn main() {\n let data: [u8; std::isize::MAX as usize] = [42; std::isize::MAX as usize];\n //~^ ERROR: rustc layout computation failed: SizeOverflow([u8;\n assert_eq!(data.len...
rust
chosen
[ { "from": "system", "value": "Add field() and field_mut() to FieldWithHeight\n" }, { "from": "human", "value": "use field::{Field, FieldHeight};\n\npub struct FieldWithHeight<F: Field> {\n field: F,\n height: [u16; 8],\n}\n\nimpl<F: Field> FieldWithHeight<F> {\n pub fn new() -> FieldWit...
rust
chosen
[ { "from": "system", "value": "Remove trailing comma that cause the test to fail compiling on stable\n" }, { "from": "human", "value": "use std::io::{BufRead, BufReader};\nuse std::path::PathBuf;\nuse std::process::{Command, Stdio};\n\n#[test]\nfn test() {\n let path = PathBuf::from(::std::env...
rust
chosen
[ { "from": "system", "value": "Remove unneccessary 'extern crate' declaration.\n" }, { "from": "human", "value": "extern crate slog;\n\nuse std::time::Instant;\nuse slog::Logger;\n\n// When this struct is dropped, it logs a message stating its name and how long, in seconds,\n// execution time was...
rust
chosen
[ { "from": "system", "value": "Rename read_usize_range to read_range and make it generic\n" }, { "from": "human", "value": "use error::InputError;\nuse std::io;\n\npub fn read_line() -> io::Result<String> {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer)?;\n\n // T...
rust
chosen
[ { "from": "system", "value": "[Tests] Add failure case for assert_impl\n" }, { "from": "human", "value": "#![no_std]\n\n#[macro_use]\nextern crate static_assertions;\n\nassert_impl!(byte; u8, Send, Sync);\n\n#[test]\nfn str_impl() {\n assert_impl!(str, Send, Sync, AsRef<[u8]>);\n}\n" }, {...
rust
chosen
[ { "from": "system", "value": "Add struct Tweet and implement Summarizable trait for it\n" }, { "from": "human", "value": "pub trait Summarizable {\n fn summary(&self) -> String;\n}\n\npub struct NewsArticle {\n pub headline: String,\n pub location: String,\n pub author: String,\n ...
rust
chosen
[ { "from": "system", "value": "Make quantization functions work for any block size.\n" }, { "from": "human", "value": "extern {\n static dc_qlookup_Q3: [i16; 256];\n static ac_qlookup_Q3: [i16; 256];\n}\n\npub fn dc_q(qindex: usize) -> i16 {\n unsafe {\n dc_qlookup_Q3[qindex]\n ...
rust
chosen
[ { "from": "system", "value": "Update NameAndSpan after rustc refactor\n" }, { "from": "human", "value": "use syntax;\nuse syntax::codemap::DUMMY_SP;\nuse syntax::ext::base::ExtCtxt;\nuse syntax::feature_gate::GatedCfg;\n\n/// Create a fake ExtCtxt to perform macro quasiquotes outside of rustc pl...
rust
chosen
[ { "from": "system", "value": "Use 'static lifetime bound to require that geom is a real struct\n\nThis bound requires that the underlying object implementing the trait\nis a real struct, not a reference or etc. See http://stackoverflow.com/questions/26212397/rust-lang-references-to-traits-in-structs/2621329...
rust
chosen
[ { "from": "system", "value": "Allow Rectangle to return its own size as well as width/height\n" }, { "from": "human", "value": "use util::units::{Point, Size};\n\npub struct Rectangle {\n location: Point,\n size: Size,\n}\n\nimpl Rectangle {\n\n pub fn new(location: Point, size: Size) -...
rust
chosen
[ { "from": "system", "value": ":art: Make possible to take argument in subcommand\n\n" }, { "from": "human", "value": "extern crate clap;\nextern crate hyper;\n#[macro_use]\nextern crate serde_derive;\nextern crate serde_json;\nextern crate toml;\n\nmod config;\nmod issue;\nmod jira_api;\nmod jir...
rust
chosen
[ { "from": "system", "value": "Handle return value in example.\n" }, { "from": "human", "value": "extern crate lcm;\n\n// mod exlcm;\nmod exlcm {\n include!(concat!(env!(\"OUT_DIR\"), \"/exlcm/example_t.rs\"));\n}\n\n// mod exlcm_backup;\n// use exlcm_backup as exlcm;\n\nfn main() {\n let m...
rust
chosen
[ { "from": "system", "value": "Print minimum value as 0%" }, { "from": "human", "value": "# Rust solution via @jrick\n\nuse std::cmp;\nuse std::num::{Int, NumCast};\n\nfn percents<T: Int>(input: &Vec<T>) -> Vec<f64> {\n let mul = f64::from(input.iter().fold(T::zero(), |m, &e| cmp::max(m, e)))....
rust
chosen