conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Implement to_string as trait in infer_schema/TableData\n" }, { "from": "human", "value": "use std::ops::Deref;\n\nuse quote;\n\n#[derive(Debug, Clone)]\npub struct TableData {\n /// Table name\n name: String,\n /// Schema name\n schema: Option<String>,\n...
rust
chosen
[ { "from": "system", "value": "Make it regression test of issue-77668\n" }, { "from": "human", "value": "#![crate_type = \"lib\"]\n\npub fn bar<P>( // Error won't happen if \"bar\" is not generic\n _baz: P,\n) {\n hide_foo()();\n}\n\nfn hide_foo() -> impl Fn() { // Error won't happen if \"i...
rust
chosen
[ { "from": "system", "value": "Use clap macros for version and author\n" }, { "from": "human", "value": "extern crate clap;\n\nuse clap::{App, Arg};\n\nfn main() {\n\n let matches = App::new(\"aux2bib\")\n .version(\"0.1.0\")\n .author(\"Nathan Mus...
rust
chosen
[ { "from": "system", "value": "Replace the hand-crafted array to u64/u32 conversions by the std one\n" }, { "from": "human", "value": "#[inline]\npub(crate) fn u64_to_arr(number: u64) -> [u8; 8] {\n number.to_le_bytes()\n}\n\n#[inline]\npub(crate) fn arr_to_u64(arr: &[u8]) -> u64 {\n debug_...
rust
chosen
[ { "from": "system", "value": "Add documentation for Frame fields\n" }, { "from": "human", "value": "/// Maximum number of channels supported in the FLAC format.\npub const MAX_CHANNELS: usize = 8;\n\n/// Audio frame that contains one sample for each channel.\npub struct Frame {\n pub header: He...
rust
chosen
[ { "from": "system", "value": "Use a closure for drop odd\n" }, { "from": "human", "value": "extern crate libnfqueue as nfq;\n\nuse nfq::{Handle, ProtocolFamily, CopyMode, VerdictHandler, Message, Verdict};\n\nfn main() {\n let mut handle = Handle::new().ok().unwrap();\n let mut queue = han...
rust
chosen
[ { "from": "system", "value": "Remove unused variable and import warnings\n" }, { "from": "human", "value": "use super::schema::notes;\nuse rocket::{Request, Data, Outcome};\nuse rocket::data::{self, FromData};\nuse rocket::http::Status;\nuse rocket::Outcome::*;\nuse serde_json;\nuse rocket_contr...
rust
chosen
[ { "from": "system", "value": "Define NotifyNotification directly instead of using a type alias\n" }, { "from": "human", "value": "use gobject::GObject;\nuse libc::c_char;\nuse glib::GError;\n\npub type NotifyNotification = _NotifyNotification;\n\n#[repr(C)]\nstruct NotifyNotificationPrivate;\n\n...
rust
chosen
[ { "from": "system", "value": "Work around rustup fallback error on Windows\n" }, { "from": "human", "value": "#[test]\nfn fmt() {\n if option_env!(\"RUSTC_TEST_SUITE\").is_some() {\n return;\n }\n\n let root_dir = std::path::PathBuf::from(env!(\"CARGO_MANIFEST_DIR\"));\n let d...
rust
chosen
[ { "from": "system", "value": "Add a new 'mutable' trait to treenode\n" }, { "from": "human", "value": "use super::values::*;\n\n///\n/// The treenode trait is implemented by things that can act as part of a tree\n///\npub trait TreeNode {\n ///\n /// Counts the number of children of this t...
rust
chosen
[ { "from": "system", "value": "[network] Add documentation for Direct Send Message\n" }, { "from": "human", "value": "// Copyright (c) The Diem Core Contributors\n// SPDX-License-Identifier: Apache-2.0\n\nuse crate::{protocols::network::SerializedRequest, ProtocolId};\nuse bytes::Bytes;\nuse serd...
rust
chosen
[ { "from": "system", "value": "Change parsing tests to snake case\n" }, { "from": "human", "value": "extern crate lrs;\n\n#[test]\nfn parse_Num() {\n\n}\n\n#[test]\nfn parse_Sym() {\n\n}\n\n#[test]\nfn parse_Atom() {\n\n}\n\n#[test]\nfn parse_List() {\n\n}\n\n#[test]\nfn parse_Expr() {\n\n}\n\n#[...
rust
chosen
[ { "from": "system", "value": "Define equality, hashing, ordering for Address.\n" }, { "from": "human", "value": "// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n// <LICENSE-MIT or http://opensource.org/licen...
rust
chosen
[ { "from": "system", "value": "DummyRenderer: Save last frame of output\n" }, { "from": "human", "value": "//! Dummy frontend that does nothing.\n\nuse frontend_api::{FrontendAction, Renderer, AudioSink};\n\n/// Renderer that just does nothing.\n#[derive(Default)]\npub struct DummyRenderer;\n\nim...
rust
chosen
[ { "from": "system", "value": "Add method to unwrap GcLeaf values.\n\nI tried `impl Into<T> for GcLeaf<T>` but there was some conflict.\n" }, { "from": "human", "value": "use std;\n\n/// GcLeaf can be used to embed just about anything in a GC heap type.\n#[derive(Copy, Clone, Debug, PartialEq)]\n...
rust
chosen
[ { "from": "system", "value": "Switch reporters to using display format\n" }, { "from": "human", "value": "\nuse nom::{Err, Needed};\n\npub fn report_error(err: Err<&[u8], u32>) {\n match err {\n Err::Code(_) => {\n println!(\"Parsing error: Unknown origin\");\n }\n ...
rust
chosen
[ { "from": "system", "value": "Include the note in the test.\n" }, { "from": "human", "value": "struct S {}\n\ntrait T<'a> {\n type A;\n}\n\nimpl T<'_> for S {\n type A = u32;\n}\n\nfn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {}\n//~^ ERROR binding for associated type `Output` re...
rust
chosen
[ { "from": "system", "value": "Implement converting from fahrenheit to celsius\n" }, { "from": "human", "value": "fn main() {\n println!(\"Hello, world!\");\n}\n" }, { "from": "gpt", "value": "use std::io;\n\nfn main() {\n println!(\"Enter value in Fahrenheit:\");\n\n let mut...
rust
chosen
[ { "from": "system", "value": "Use c_int instead of c_uint to be more inline with termbox\n" }, { "from": "human", "value": "#![feature(libc)]\nextern crate libc;\n\nuse libc::{c_int, c_uint};\n\n#[repr(C)]\n#[derive(Copy)]\npub struct RawEvent {\n pub etype: u8,\n pub emod: u8,\n pub ke...
rust
chosen
[ { "from": "system", "value": "Add basic `RefInto` and `MutInto` implementations\n" }, { "from": "human", "value": "pub trait RefInto<'a, T>: MutInto<'a, T> {\n fn ref_into(&'a self) -> T;\n}\n\npub trait MutInto<'a, T> {\n fn mut_into(&'a mut self) -> T;\n}\n" }, { "from": "gpt", ...
rust
chosen
[ { "from": "system", "value": "Update fuzzer script to previous commit's changes\n" }, { "from": "human", "value": "#![no_main]\n#[macro_use] extern crate libfuzzer_sys;\nextern crate inf_4301a;\n\nuse std::str;\n\nfuzz_target!(|data: &[u8]| {\n\n if let Ok(ref s) = str::from_utf8(data) {\n ...
rust
chosen
[ { "from": "system", "value": "Use imports to shorten lines\n" }, { "from": "human", "value": "extern crate capnpc;\n\nfn main() {\n\n // CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include\n\n let prefix = {\n let output = ::std::process::Command::new(\"which\").arg(\...
rust
chosen
[ { "from": "system", "value": "Add dummy `unimplemented!()` for cocoa api\n" }, { "from": "human", "value": "use {SystrayError};\n\npub struct Window {\n}\n\nimpl Window {\n pub fn new() -> Result<Window, SystrayError> {\n Err(SystrayError::NotImplementedError)\n }\n}\n" }, { ...
rust
chosen
[ { "from": "system", "value": "Fix TODO: Use triple fault to guarantee reboot\n\nCause interrupt, since the IDT is dorked we can't find the INT 3\nhandler (double fault), and the double fault handler can't be\nfound (triple fault).\n" }, { "from": "human", "value": "#[cfg(feature = \"acpi\")]\nus...
rust
chosen
[ { "from": "system", "value": "test: Fix a pretty printing test\n\nThe pretty printer handles inlines comments quite badly\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
chosen
[ { "from": "system", "value": "Simplify qualification with use statement\n" }, { "from": "human", "value": "mod vm;\nmod command;\nmod parse;\nmod program;\n\nuse vm::VM;\nuse program::Program;\nuse std::io::Write;\nuse std::env;\nuse std::path::Path;\nuse std::fs::File;\nuse std::io::prelude::*;...
rust
chosen
[ { "from": "system", "value": "Refactor trait implementationf or `PortMidiError`\n\n- `Display` implementation was basically the same as `Debug`\n" }, { "from": "human", "value": "use std::fmt::{Display, Formatter, Error as FormatError};\nuse std::error::Error;\n\npub type PortMidiDeviceId = i32;...
rust
chosen
[ { "from": "system", "value": "Update evaluate tool to parse a file\n" }, { "from": "human", "value": "extern crate document;\nextern crate xpath;\n\nuse std::collections::hashmap::HashMap;\n\nuse document::{Document,ToAny};\n\nuse xpath::{XPathEvaluationContext,XPathFactory};\nuse xpath::express...
rust
chosen
[ { "from": "system", "value": "Remove unused extern crate rustc_trans.\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;\ne...
rust
chosen
[ { "from": "system", "value": "Trim down the crate attribute listings\n" }, { "from": "human", "value": "// Copyright 2012-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...
rust
chosen
[ { "from": "system", "value": "Add serialize implementation for u64\n" }, { "from": "human", "value": "use std::io;\n\nuse tag;\nuse err;\nuse serial;\n\nimpl serial::traits::Asn1Info for u64 {\n fn asn1_type(&self) -> tag::Type {\n tag::Type::from(\"INTEGER\")\n }\n\n fn asn1_class(&self) ...
rust
chosen
[ { "from": "system", "value": "Fix gl exports in certain circumstances\n" }, { "from": "human", "value": "extern crate gl as gl_lib;\n\nmod context;\n\npub use gl_lib as gl;\npub use context::Context;\n" }, { "from": "gpt", "value": "extern crate gl as gl_lib;\n\nmod context;\n\npub m...
rust
chosen
[ { "from": "system", "value": "Make dummy font implementation conform to API changes.\n" }, { "from": "human", "value": "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at h...
rust
chosen
[ { "from": "system", "value": "Use a proper protocol definition instead of the already-expanded code.\n" }, { "from": "human", "value": "// Generated from pipe compiler\nmod stream {\n fn init<T: send>() -> (client::stream<T>, server::stream<T>) {\n pipes::entangle()\n }\n enum st...
rust
chosen
[ { "from": "system", "value": "Add error banner when running test suite without nightly compiler\n" }, { "from": "human", "value": "// Copyright 2017 Serde Developers\n//\n// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n// http://www.apache.org/licenses/LICENSE-2.0> or the M...
rust
chosen
[ { "from": "system", "value": "[sup,core] Set optional PATH when shelling out for ip & hostname.\n\nThis fixes an issue we are seeing in the Supervisor when the default\nbind address is being determined. In minimal environments (such as in a\nStudio, in a Docker container, etc) the `ip` and `hostname` comman...
rust
chosen
[ { "from": "system", "value": "Implement deref for Buffered wrapper\n" }, { "from": "human", "value": "//! Tools for wrapping devices.\n\nuse types::{AudioDevice, Sample, Time};\n\n\n/// Bundles an AudioDevice with allocated input and output buffers.\n///\n/// To use the device, input samples mus...
rust
chosen
[ { "from": "system", "value": "Revert \"Add Sized trait to ElementType\"\n\nThis reverts commit db23b9ec7387b6b5e7caf880e5ef95eb49789a45.\n" }, { "from": "human", "value": "#![feature(zero_one, box_syntax)]\n\nextern crate asexp;\n\npub mod num_expr;\npub mod cond;\n\nuse std::fmt::Debug;\nuse st...
rust
chosen
[ { "from": "system", "value": "Fix struct syntax for empty struct\n\n* MainState in flappy example\n" }, { "from": "human", "value": "extern crate ggez;\n\nuse ggez::{Game, State, GameError};\nuse std::time::Duration;\n\nstruct MainState\n{\n}\n\nimpl State for MainState\n{\n fn init(&mut self...
rust
chosen
[ { "from": "system", "value": "Add trait implementation for SubAssign\n" }, { "from": "human", "value": "use std::ops::{Add, AddAssign, Sub};\n\n#[derive(Debug, Copy, Clone)]\npub struct Vec3 {\n pub i : f64,\n pub j : f64,\n pub k : f64,\n}\n\nimpl Vec3 {\n pub fn length(&self) -> f64 {\n ...
rust
chosen
[ { "from": "system", "value": "Fix unused attribute warning regarding the license attribute\n" }, { "from": "human", "value": "// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n// <LICENSE-MIT or http://opensou...
rust
chosen
[ { "from": "system", "value": "[opentitantool] Fix typo in CW310 backend\n\nSigned-off-by: Jorge Prendes <e1833ed3bb567a7d246d72b65c4144d1037bd875@gmail.com>\n" }, { "from": "human", "value": "// Copyright lowRISC contributors.\n// Licensed under the Apache License, Version 2.0, see LICENSE for d...
rust
chosen
[ { "from": "system", "value": "Add FIXME to file reading test\n" }, { "from": "human", "value": "// ignore-windows: File handling is not implemented yet\n// compile-flags: -Zmiri-disable-isolation\n\nuse std::fs::File;\nuse std::io::Read;\n\nfn main() {\n let mut file = File::open(\"./tests/he...
rust
chosen
[ { "from": "system", "value": "test: Fix name of bitv type\n" }, { "from": "human", "value": "// error-pattern: mismatched types\nuse std;\nimport std::map::hashmap;\nimport std::bitv;\n\ntype fn_info = {vars: hashmap<uint, var_info>};\ntype var_info = {a: uint, b: uint};\n\nfn bitv_to_str(enclos...
rust
chosen
[ { "from": "system", "value": "Fix the UUID Parcel implementation\n" }, { "from": "human", "value": "use {Parcel, Error, Settings};\nuse std::io::prelude::*;\n\nuse uuid::Uuid;\n\nimpl Parcel for Uuid\n{\n fn read(read: &mut Read,\n settings: &Settings,\n _: &mut hint::Hi...
rust
chosen
[ { "from": "system", "value": "Add a `stop` function to `Application`.\n" }, { "from": "human", "value": "use glutin::Window;\n\nuse event::{Event, PollEvents, Reactor};\nuse render::{Context, GlutinContext, MetaContext};\n\npub struct Harness<A, C>\n where A: Application<C>,\n C: Met...
rust
chosen
[ { "from": "system", "value": "Add basic packet read, including unsafe conversion\n" }, { "from": "human", "value": "//! Contains code to handle an IPC channel which is issuing commands.\n\nuse std::io::prelude::*;\n\nuse rustc_serialize::Decodable;\nuse rustc_serialize::json::{Json, ToJson, Deco...
rust
chosen
[ { "from": "system", "value": "Allow append_path to be unused\n" }, { "from": "human", "value": "use std::ffi::OsString;\nuse std::env;\nuse std::path::{Path, PathBuf};\nuse std::process::Command;\n\npub fn append_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) {\n let old_value = env...
rust
chosen
[ { "from": "system", "value": "Use clap's required_unless to enforce input file path\n" }, { "from": "human", "value": "mod gen;\nmod syntax;\n\nuse gen::include;\nuse std::io::{self, Write};\nuse std::path::PathBuf;\nuse std::process;\nuse structopt::StructOpt;\n\n#[derive(StructOpt, Debug)]\n#[...
rust
chosen
[ { "from": "system", "value": "Add optional search path for static linking\n" }, { "from": "human", "value": "fn main() {\n if cfg!(r#static) {\n println!(\"cargo:rustc-link-lib=static=odbc\");\n }\n\n if cfg!(target_os = \"macos\") {\n // if we're on Mac OS X we'll kindly ...
rust
chosen
[ { "from": "system", "value": "Improve previous compile fail test\n" }, { "from": "human", "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": "system", "value": "Add short documentation of the root module for `client`\n" }, { "from": "human", "value": "extern crate base;\n#[macro_use]\nextern crate glium;\n#[macro_use]\nextern crate log;\n\npub mod render;\npub mod event_manager;\nmod config;\nmod game;\n\npub use config::Co...
rust
chosen
[ { "from": "system", "value": "Fix regression in line ending test\n" }, { "from": "human", "value": "// run-pass\n// ignore-tidy-cr\n\n// this file has some special \\r\\n endings (use xxd to see them)\n\nfn main() {assert_eq!(b\"\", b\"\\\n \");\nassert_eq!(b\"\...
rust
chosen
[ { "from": "system", "value": "Remove 'u' from number literals" }, { "from": "human", "value": "extern crate rust_guessing_game;\n\nuse std::old_io as io;\nuse std::rand;\nuse std::cmp::Ordering;\n\nuse rust_guessing_game::my_funcs;\n\n#[cfg(not(test))]\nfn main() {\n println!(\"Guess the magi...
rust
chosen
[ { "from": "system", "value": "Sort import by specificity, then alphabetize.\n\nSigned-off-by: mulhern <7b51bcf507bcd7afb72bf8663752c0ddbeb517f6@redhat.com>\n" }, { "from": "human", "value": "// This Source Code Form is subject to the terms of the Mozilla Public\n// License, v. 2.0. If a copy of ...
rust
chosen
[ { "from": "system", "value": "Add function to convert roman numerals into decimal numbers.\n" }, { "from": "human", "value": "/*\n** A simple program that allows basic arithmetic operations using roman numerals and conversions to decimal numbers.\n*/\n\nfn main() {\n println!(\"Bismillah\");\...
rust
chosen
[ { "from": "system", "value": "Add file allow annotations for warnings\n" }, { "from": "human", "value": "use syntax::ast;\nuse syntax::ast::{MetaItem, Expr};\nuse syntax::codemap::Span;\nuse syntax::ext::base::{Annotatable, ExtCtxt};\nuse syntax::ext::build::AstBuilder;\nuse syntax::ext::derivin...
rust
chosen
[ { "from": "system", "value": "Remove unneeded features (and unneeded attribute)\n" }, { "from": "human", "value": "#![cfg_attr(feature=\"clippy\", feature(plugin))]\n#![cfg_attr(feature=\"clippy\", plugin(clippy))]\n#![feature(conservative_impl_trait)]\n#![feature(collections_bound)]\n#![feature...
rust
chosen
[ { "from": "system", "value": "Test is the file actually is created\n" }, { "from": "human", "value": "#[macro_use]\nextern crate serde_elm;\n\n#[allow(dead_code)]\n#[derive(Elm)]\nstruct Simple {\n name: String\n}\n\n#[test]\nfn should_assert_elm_generation_was_done() {\n assert!(true);\n}...
rust
chosen
[ { "from": "system", "value": "Improve documentation for new Validation trait\n" }, { "from": "human", "value": "/// Validation provider\npub trait Validator {\n fn is_valid(&self, line: &str) -> bool;\n}\n\nimpl Validator for () {\n fn is_valid(&self, _line: &str) -> bool {\n true\n...
rust
chosen
[ { "from": "system", "value": "Make sure the submodule is brought in\n" }, { "from": "human", "value": "use std::io::Command;\nuse std::os;\n\nfn main() {\n let curr_dir = os::getenv(\"CARGO_MANIFEST_DIR\").unwrap();\n let nvim_dir = Path::new(curr_dir).join(\"neovim\");\n Command::new(\...
rust
chosen
[ { "from": "system", "value": "Use Inline assembly for msvc target from non-windows host\n\nWhen cross-compiling for msvc from a non-windows host, inline assembly is typically supported (for example via clang or clang-cl). Given that clang also doesn't support masm or have ml.exe compatibility, it's best to ...
rust
chosen
[ { "from": "system", "value": "Remove unnecessary referencing in the hash comparison\n" }, { "from": "human", "value": "use data_encoding::{BASE64URL, DecodeError};\n\npub fn check_access_token<T: AsRef<str>>(token: T, salt: T, hash: T) -> bool {\n let hashed_token = salt_and_hash(salt, token)...
rust
chosen
[ { "from": "system", "value": "Add `IndexDatum` impls for `u8`/`u16`\n" }, { "from": "human", "value": "pub use std::mem;\npub use std::slice;\n\npub enum IndexDatumType {\n UnsignedByte,\n UnsignedShort\n}\n\npub trait IndexData {\n fn index_datum_type() -> IndexDatumType;\n fn index...
rust
chosen
[ { "from": "system", "value": "Print message instead of disabling challenge\n" }, { "from": "human", "value": "use super::hmac_client;\nuse super::hmac_server;\n\nuse rand;\nuse rand::Rng;\n\nuse errors::*;\n\npub fn run() -> Result<(), Error> {\n let skip_exercise = true;\n\n if skip_exerc...
rust
chosen
[ { "from": "system", "value": "Fix nightly check in serde-syntex-example\n" }, { "from": "human", "value": "#![cfg_attr(nightly, feature(custom_derive, plugin))]\n#![cfg_attr(nightly, plugin(serde_macros))]\n\nextern crate serde;\nextern crate serde_json;\n\n#[cfg(feature = \"serde_macros\")]\nin...
rust
chosen
[ { "from": "system", "value": "Handle divide by zero errors\n" }, { "from": "human", "value": "use parser::Expr;\nuse parser::Expr::*;\n\n// The main entry point for the calculator itself.\n// It receives an expression tree, and recursively reduces it to a single signed 64-bit integer\npub fn eva...
rust
chosen
[ { "from": "system", "value": "Rename List to Repository to avoid ambiguity\n" }, { "from": "human", "value": "enum PackageType {\n Bin, // Binary\n Lib, // Library\n Src, // Source\n}\n\nstruct Version {\n major: u32,\n minor: u32,\n patch: u32,\n additional: Option<String>,...
rust
chosen
[ { "from": "system", "value": "Add fixme for parsing error\n" }, { "from": "human", "value": "use std::fmt;\nuse std::error::Error;\n\n#[derive(Debug)]\npub struct ParsingError {\n desc: String,\n}\n\nimpl fmt::Display for ParsingError {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Resul...
rust
chosen
[ { "from": "system", "value": "Enable an old test that works now!\n" }, { "from": "human", "value": "use std::cell::Cell;\nuse std::rc::Rc;\nuse std::sync::Arc;\n\nfn rc_cell() -> Rc<Cell<i32>> {\n let r = Rc::new(Cell::new(42));\n let x = r.get();\n r.set(x + x);\n r\n}\n\n// TODO(so...
rust
chosen
[ { "from": "system", "value": "Add example of usage tests from file `Readme.md`\n" }, { "from": "human", "value": "#![ warn( missing_docs ) ]\n#![ warn( missing_debug_implementations ) ]\n\n//!\n//! Basic exceptions handling mechanism.\n//!\n//! # Sample\n//! ```\n//! use werror::*;\n//!\n//! let...
rust
chosen
[ { "from": "system", "value": "chore: Remove platform check for syntax-highlight\n\nNow that there is `null` syntax highlighting, let people attempt to\nenable the real version if they want to, even on unsupported platforms.\n\nReally, the motivation is I'm running into a rustfmt bug and trying to\nwork arou...
rust
chosen
[ { "from": "system", "value": "Simplify GistFile's read functions return types.\n" }, { "from": "human", "value": "extern crate rustc_serialize;\n\nuse self::rustc_serialize::json::{ToJson, Json};\nuse std::collections::BTreeMap;\n\nuse std::fs::File;\nuse std::io::{self, Read};\nuse std::path::P...
rust
chosen
[ { "from": "system", "value": "Debug print the dev syntax tree\n" }, { "from": "human", "value": "extern crate proc_macro;\n\nuse proc_macro::TokenStream;\nuse syn::{parse_macro_input, File};\n\n#[proc_macro]\npub fn r#mod(input: TokenStream) -> TokenStream {\n parse_macro_input!(input as File...
rust
chosen
[ { "from": "system", "value": "Rename JsType to JsT, JsT to JsTrait\n" }, { "from": "human", "value": "use std::cmp::Ordering;\nuse std::hash::{Hash, Hasher};\nuse uuid::Uuid;\n\npub struct JsType {\n uid: Uuid,\n t: Box<JsT>,\n}\n\nimpl JsType {\n fn new(t: Box<JsT>) -> JsType {\n ...
rust
chosen
[ { "from": "system", "value": "Return an error result, instead of pretending unimplemented commands are ok\n" }, { "from": "human", "value": "#[macro_use]\nextern crate clap;\n#[macro_use]\nextern crate log;\nextern crate git2;\n\nmod cd;\nmod cli;\nmod logger;\nmod repository;\nmod settings;\n\n...
rust
chosen
[ { "from": "system", "value": "Add derive debug to RegistryValue\n" }, { "from": "human", "value": "//! Types used in the registry.\n\nuse std::fmt::{Debug, Display, Formatter};\n\nuse std::sync::Arc;\nuse rustc_serialize::{Encodable, Decodable};\nuse rustc_serialize::json::{Json, ToJson};\n\n///...
rust
chosen
[ { "from": "system", "value": "Add tests for declare_lint_pass and impl_lint_pass\n" }, { "from": "human", "value": "#![deny(clippy::internal)]\n#![feature(rustc_private)]\n\n#[macro_use]\nextern crate rustc;\nuse rustc::lint;\n\n#[macro_use]\nextern crate clippy_lints;\n\ndeclare_clippy_lint! {\...
rust
chosen
[ { "from": "system", "value": "Convert 1mm points in test\n" }, { "from": "human", "value": "// this is just a test binary that can be hooked up to Instruments\nextern crate lonlat_bng;\nuse lonlat_bng::{convert_to_bng_threaded, Array};\n\nextern crate rand;\nuse rand::distributions::{Independent...
rust
chosen
[ { "from": "system", "value": "Add a commented-out RefCell 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::n...
rust
chosen
[ { "from": "human", "value": "Refactor the ConstantOrigin shape to the query module.\n" }, { "from": "gpt", "value": "use na::{RealField, Unit};\n\nuse crate::math::{Isometry, Point, Vector};\nuse crate::shape::SupportMap;\n\n/// A support mapping that is always equal to the origin, independently...
rust
chosen
[ { "from": "system", "value": "Move reexport to the other reexports\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 specifica...
rust
chosen
[ { "from": "system", "value": "Remove unused StoreTrue from example\n" }, { "from": "human", "value": "extern crate tvdb;\nextern crate argparse;\n\nuse argparse::{ArgumentParser, StoreTrue, Store};\n\n\nfn main(){\n let mut series_name = \"\".to_owned();\n let mut season_no = 1;\n let m...
rust
chosen
[ { "from": "system", "value": "Write a test file to generated directory\n" }, { "from": "human", "value": "extern crate syn;\n\nuse syn::DeriveInput;\n\npub fn generate_elm(_: &DeriveInput) {\n // do nothing\n}\n" }, { "from": "gpt", "value": "extern crate syn;\n\nuse std::env;\nus...
rust
chosen
[ { "from": "system", "value": "Make the error stack type public\n" }, { "from": "human", "value": "pub enum ErrorLevel {\n Info,\n Warning,\n Error,\n}\n\n// Use a hashmap which contains an error level and a string\ntype ErrorStack = Vec<(ErrorLevel, String)>;" }, { "from": "gpt"...
rust
chosen
[ { "from": "system", "value": "Define `OscMessage` and `OscBundle` structs\n" }, { "from": "human", "value": "use errors;\n\n// 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(Stri...
rust
chosen
[ { "from": "system", "value": "Rewrite the FPE test to not use Context directly\n" }, { "from": "human", "value": "// This file is part of libfringe, a low-level green threading library.\n// Copyright (c) Ben Segall <talchas@gmail.com>\n// Copyright (c) edef <edef@edef.eu>\n// See the LICENSE fil...
rust
chosen
[ { "from": "system", "value": "Test fix: Ensuring db cleanup doesn't happen until after test completion...\n" }, { "from": "human", "value": "// Copyright 2014 Tyler Neely\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance ...
rust
chosen
[ { "from": "system", "value": "Support for the new constraint.\n" }, { "from": "human", "value": "use traits::Grid;\nuse traits::Engine;\nuse traits::Consumer;\n\n\npub struct Sequential<G: Grid, C: Consumer> {\n grid: G,\n consumer: C\n}\n\nimpl<G: Grid, C: Consumer> Sequential<G, C> {\n\n...
rust
chosen
[ { "from": "system", "value": "Correct pointer size cfg variables\n" }, { "from": "human", "value": "pub trait Key: Copy + PartialEq + Ord + Default {\n type Bytes: AsRef<[u8]>;\n fn into_bytes(self) -> Self::Bytes;\n fn from_bytes(bytes: Self::Bytes) -> Self;\n}\n\n\nmacro_rules! impl_k...
rust
chosen
[ { "from": "system", "value": "Change incrementor to be more generic\n" }, { "from": "human", "value": "use std::cell::Cell;\n\npub trait Incrementor {\n fn increment(&self);\n}\n\nimpl Incrementor for Cell<u8> {\n fn increment(&self) {\n self.set(self.get() + 1);\n }\n}\n\nimpl I...
rust
chosen
[ { "from": "system", "value": "Break out of loop if can't send data\n\nFixes #4046\n" }, { "from": "human", "value": "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http...
rust
chosen
[ { "from": "system", "value": "Make RepositoryList and its field public\n" }, { "from": "human", "value": "use std::fs::File;\nuse std::io::Read;\nuse std::path::Path;\nuse toml::Value as Toml;\n\nuse error::PackageError;\nuse package::Package;\n\n/// The struct which represents the repos.\n#[der...
rust
chosen
[ { "from": "system", "value": "Check if empty after normalization\n" }, { "from": "human", "value": "#![feature(slice_concat_ext)]\n\nuse unicode_segmentation::UnicodeSegmentation;\nuse std::slice::SliceConcatExt;\n\nextern crate unicode_segmentation;\n\npub fn normalize_tag(tag: &str) -> Result<...
rust
chosen
[ { "from": "system", "value": "Allow `non_snake_case` in the generated code.\n" }, { "from": "human", "value": "#![feature(plugin_registrar, quote)]\nextern crate rustc;\nextern crate syntax;\n\nuse rustc::plugin::Registry;\nuse syntax::ast::TokenTree;\nuse syntax::codemap::Span;\nuse syntax::ext...
rust
chosen
[ { "from": "system", "value": "Add feature annotations for currently unstable features used\n" }, { "from": "human", "value": "#[macro_use] extern crate log;\nextern crate \"rustc-serialize\" as rustc_serialize;\n\npub mod hpack;\npub mod http;\npub mod client;\n\nmod tests {\n}\n" }, { "...
rust
chosen
[ { "from": "system", "value": "Use std::rt::io::Timer instead of an unsafe sleep()\n" }, { "from": "human", "value": "/*!\n * Hello World server in Rust\n * Binds REP socket to tcp://*:5555\n * Expects \"Hello\" from client, replies with \"World\"\n */\n\nextern mod zmq;\n\nuse std::libc;\n\nfn m...
rust
chosen
[ { "from": "system", "value": "Add new type for an URL\n" }, { "from": "human", "value": "extern crate hyper;\nextern crate pbr;\nextern crate ansi_term;\n\nuse std::sync::{Arc, Mutex};\n\n#[macro_use]\npub mod logs;\n\npub mod authorization;\npub mod cargo_helper;\npub mod client;\npub mod conte...
rust
chosen
[ { "from": "system", "value": "Change BufferID type -> String\n" }, { "from": "human", "value": "//! This is the `custom types` module for Xtensis.\n\n// This file is part of Xtensis.\n\n// This is the Xtensis text editor; it edits text.\n// Copyright (C) 2016-2017 The Xtensis Developers\n\n// T...
rust
chosen
[ { "from": "system", "value": "Add test for trait check in prelude collision lint.\n" }, { "from": "human", "value": "// edition:2018\n// check-pass\n#![allow(unused)]\n#![deny(rust_2021_prelude_collisions)]\n\nstruct S;\n\nimpl S {\n fn try_into(self) -> S {\n S\n }\n}\n\n// See htt...
rust
chosen