conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Add `ByteStream` for entire files of a byte slice\n" }, { "from": "human", "value": "use nom::IResult;\n\npub trait StreamProducer {\n fn parse<F, T>(&mut self, f: F) -> Result<T, ErrorKind>\n where F: FnOnce(&[u8]) -> IResult<&[u8], T>;\n}\n" }, { "from"...
rust
chosen
[ { "from": "system", "value": "Add Sealed supertrait to private AsDynError trait\n" }, { "from": "human", "value": "use std::error::Error;\nuse std::panic::UnwindSafe;\n\npub trait AsDynError<'a> {\n fn as_dyn_error(&self) -> &(dyn Error + 'a);\n}\n\nimpl<'a, T: Error + 'a> AsDynError<'a> for ...
rust
chosen
[ { "from": "system", "value": "Drop type annotation from example\n" }, { "from": "human", "value": "extern crate ndarray;\nextern crate ndarray_linalg;\n\nuse ndarray::*;\nuse ndarray_linalg::*;\n\nfn main() {\n let a = arr2(&[[3.0, 1.0, 1.0], [1.0, 3.0, 1.0], [1.0, 1.0, 3.0]]);\n let (e, v...
rust
chosen
[ { "from": "system", "value": "chore(cli): Move non-essential status output to STDERR\n" }, { "from": "human", "value": "pub mod cli;\npub mod i18n;\npub mod make;\npub mod setup;\npub mod shell;\nuse fluent::{FluentArgs, FluentValue};\n\npub static DEFAULT_LOCALE: &'static str = \"en-US\";\n\n#[...
rust
chosen
[ { "from": "system", "value": "Fix a test that broke on a recent nightly\n" }, { "from": "human", "value": "#![feature(plugin)]\n#![plugin(plague)]\n\nplague! {\n for [ //~ERROR: this function takes 0 parameters but 2 parameters were supplied\n (1, 2),\n ]\n test fn foo() {\n }...
rust
chosen
[ { "from": "system", "value": "Define struct to represent template metadata\n" }, { "from": "human", "value": "extern crate askama;\nextern crate proc_macro;\nextern crate syn;\n\nuse proc_macro::TokenStream;\n\nfn get_path_from_attrs(attrs: &[syn::Attribute]) -> String {\n let attr = attrs.it...
rust
chosen
[ { "from": "system", "value": "CG: Use new version of gtk:init() that returns a Result\n" }, { "from": "human", "value": "extern crate gtk;\n\nuse gtk::traits::*;\n\nfn main() {\n if !gtk::init_check() {\n println!(\"Cannot start because GTK is not working / available\");\n retur...
rust
chosen
[ { "from": "system", "value": "Add as_boolean and as_symbol to AnyObject\n" }, { "from": "human", "value": "use std::convert::From;\n\nuse types::Value;\n\nuse super::array::Array;\nuse super::class::Class;\nuse super::fixnum::Fixnum;\nuse super::hash::Hash;\nuse super::string::RString;\n\nuse su...
rust
chosen
[ { "from": "system", "value": "Fix point-mutations for newest rust\n" }, { "from": "human", "value": "pub fn hamming_distance(a: &str, b: &str) -> uint {\n a.chars().zip(b.chars()).filter(|&(a, b)| a != b).count()\n}\n" }, { "from": "gpt", "value": "pub fn hamming_distance(a: &str,...
rust
chosen
[ { "from": "system", "value": "Add test for Type containing macro metavariable\n" }, { "from": "human", "value": "use syn::Type;\n\n#[test]\nfn test_mut_self() {\n syn::parse_str::<Type>(\"fn(mut self)\").unwrap();\n syn::parse_str::<Type>(\"fn(mut self: ())\").unwrap();\n syn::parse_str...
rust
chosen
[ { "from": "system", "value": "Fix gen_hashmap! and improve it's performance" }, { "from": "human", "value": "#![allow(unused_macros)]\n\nmacro_rules! gen_hashmap {\n\n {$($key: expr => $value: expr),*} => {\n\n {\n let mut hashmap = HashMap::new();\n\n $(\n ...
rust
chosen
[ { "from": "system", "value": "Add DAO functionality to add category\n" }, { "from": "human", "value": "extern crate dotenv;\nextern crate diesel;\n\nuse self::dotenv::dotenv;\nuse std::env;\nuse self::diesel::prelude::*;\nuse self::diesel::pg::PgConnection;\n\npub fn establish_connection() -> Pg...
rust
chosen
[ { "from": "system", "value": "Use process::abort() instead of libc::abort() for wasm32\n" }, { "from": "human", "value": "//! Package up unwind recovery. Note that if you are in some sensitive\n//! place, you can use the `AbortIfPanic` helper to protect against\n//! accidental panics in the rayo...
rust
chosen
[ { "from": "system", "value": "bug: Fix unix import in tests for windows\n" }, { "from": "human", "value": "use assert_cmd::prelude::*;\nuse std::process::{Command, Stdio};\n\nuse anyhow::{Context, Result};\nuse nix::sys::signal::{kill, Signal};\nuse nix::unistd::Pid;\n\nmod helper;\n\nuse helper...
rust
chosen
[ { "from": "system", "value": "Allow specifying an output file on the command line\n" }, { "from": "human", "value": "use std::io;\nuse std::collections::HashSet;\n\nextern crate syn;\nextern crate clap;\n\nuse clap::{Arg, App};\n\nmod rust_lib;\nmod bindgen;\n\nfn main() {\n let matches = App...
rust
chosen
[ { "from": "system", "value": "Allow for the port to be set by env variable\n" }, { "from": "human", "value": "extern crate ratel;\nextern crate iron;\n\nuse std::io::Read;\nuse iron::prelude::*;\nuse iron::status;\nuse ratel::error::ParseError;\n\nfn compile(source: String, minify: bool) -> Resu...
rust
chosen
[ { "from": "system", "value": "Read token from environment variable\n" }, { "from": "human", "value": "fn main() {\n println!(\"Hello, world!\");\n}\n" }, { "from": "gpt", "value": "use std::{env, process};\n\nfn main() {\n let token = match env::var(\"GITHUB_SWEEP_TOKEN\") {\n ...
rust
chosen
[ { "from": "system", "value": "Improve error printing in example\n" }, { "from": "human", "value": "extern crate xswag_syntax_java as syntax;\nextern crate xswag_base as base;\n\nuse base::diag;\n\n// FIXME: import is currently wrong\nconst SRC: &'static str = \"\\\npackage yolo.swag;\n\nimport A...
rust
chosen
[ { "from": "system", "value": "Add clone derive for PngError\n" }, { "from": "human", "value": "use std::error::Error;\nuse std::fmt;\n\n#[derive(Debug)]\npub struct PngError {\n description: String,\n}\n\nimpl Error for PngError {\n fn description(&self) -> &str {\n &self.descriptio...
rust
chosen
[ { "from": "system", "value": "[doc] Hide the ioctl FFI declaration\n" }, { "from": "human", "value": "extern crate libc as real_libc;\n#[macro_use]\nextern crate bitflags;\n\n#[cfg(target_os = \"linux\")]\n#[path = \"platform/linux.rs\"]\n#[macro_use]\nmod platform;\n\npub use platform::*;\n\n//...
rust
chosen
[ { "from": "system", "value": "Change unstable flags for changes to Rust nightly.\n" }, { "from": "human", "value": "#![feature(core)]\n\nextern crate interpolate;\nextern crate num;\n\npub mod vector;\npub mod rect;\npub mod circle;\npub mod grid;\npub mod wrapping_grid;\n\npub use vector::Vec2;...
rust
chosen
[ { "from": "system", "value": "Replace match blocks with try! macro\n" }, { "from": "human", "value": "//! A crate for parsing Markdown in Rust\n#![crate_name = \"markdown\"]\n#![deny(missing_docs)]\n// #![deny(warnings)]\n\n#![cfg_attr(feature=\"clippy\", feature(plugin))]\n#![cfg_attr(feature=\...
rust
chosen
[ { "from": "system", "value": "Handle one instruction that goes one block\n" }, { "from": "human", "value": "pub fn distance(input: &str) -> i32 {\n 3\n}" }, { "from": "gpt", "value": "pub fn distance(input: &str) -> u32 {\n let mut chars = input.chars();\n if let (Some(turn_...
rust
chosen
[ { "from": "system", "value": "Remove now unused rustc_serialize crate.\n" }, { "from": "human", "value": "//! Implementation of the `Synth` struct for basic polyphonic, multi-oscillator envelope synthesis.\n\nextern crate envelope as envelope_lib;\nextern crate gaussian;\npub extern crate instru...
rust
chosen
[ { "from": "system", "value": ":art: Change the return value to the generic single type \n\n" }, { "from": "human", "value": "extern crate serde;\nextern crate serde_json;\n\nuse hyper::Client;\nuse hyper::client::{Body, Response};\nuse hyper::header::Headers;\nuse hyper::status::StatusCode;\nuse...
rust
chosen
[ { "from": "system", "value": "Fix deprecation warning for bare trait obbject.\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": "Fix build with 'nightly' feature\n" }, { "from": "human", "value": "//! termion is a pure Rust library for reading, manipulating, and handling terminals.\n//!\n//! This crate is not stable, yet. However, if you do want stability, you should specify the\n//! revision...
rust
chosen
[ { "from": "system", "value": "Use last expression instead of return\n" }, { "from": "human", "value": "\npub fn edit_distance(a: &str, b: &str) -> i32 {\n\n let row: Vec<i32> = vec![0; b.len() + 1];\n let mut matrix: Vec<Vec<i32>> = vec![row; a.len() + 1];\n\n // initialize string a\n ...
rust
chosen
[ { "from": "system", "value": "Fix the tests for OneOrMany.\n" }, { "from": "human", "value": "//use serde::de::Deserialize;\nuse super::super::link::HalLink;\nuse super::super::resource::OneOrMany;\nuse serde_json::{from_str, to_string};\nuse serde::*;\n\n#[derive(Serialize, Deserialize)]\nstruc...
rust
chosen
[ { "from": "system", "value": "Add stub root module documentation\n" }, { "from": "human", "value": "extern crate time;\nextern crate serde;\nextern crate serde_json;\n\nmod user;\nmod message;\npub mod json;\n\npub use self::user::*;\npub use self::message::*;\n" }, { "from": "gpt", ...
rust
chosen
[ { "from": "system", "value": "Drop the dependency on a macros crate\n" }, { "from": "human", "value": "#![feature(backtrace)]\n\nmod as_error;\nmod exception;\nmod context;\n\n#[doc(inline)]\n/// Annotations a function that \"throws\" a Result.\n///\n/// Inside functions tagged with `throws`, yo...
rust
chosen
[ { "from": "system", "value": "Add example to module documentation.\n" }, { "from": "human", "value": "//! Implementation of the Micro Transport Protocol.[^spec]\n//!\n//! [^spec]: http://www.bittorrent.org/beps/bep_0029.html\n\n// __________ ____ ____\n// /_ __/ __ \\/ __ \\/ __ \\\n// /...
rust
chosen
[ { "from": "system", "value": "Add Table type, Read, Write trait\n" }, { "from": "human", "value": "pub mod ascii_writer;\npub mod markdown_writer;\n" }, { "from": "gpt", "value": "pub mod ascii_writer;\npub mod markdown_writer;\n\npub struct Table {\n rows: Vec<Vec<String>>,\n has_...
rust
chosen
[ { "from": "system", "value": "Make DeleteStatement and UpdateStatement public\n" }, { "from": "human", "value": "#[macro_use]\nextern crate nom;\n\nextern crate serde;\n#[macro_use]\nextern crate serde_derive;\n\npub use self::arithmetic::{ArithmeticBase, ArithmeticExpression, ArithmeticOperator...
rust
chosen
[ { "from": "system", "value": "Make the wrapper type for Uri cloneable\n" }, { "from": "human", "value": "use hyper::Uri as HyperUri;\nuse std::path::Path;\n\n/// A convenience type that can be used to construct Unix Domain Socket URIs\n///\n/// This type implements `Into<hyper::Uri>`.\n///\n/// ...
rust
chosen
[ { "from": "system", "value": "Use eprintln from Rust 1.19\n" }, { "from": "human", "value": "/*\n * Copyright (c) 2015-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the Licens...
rust
chosen
[ { "from": "system", "value": "Simplify code to find template path\n" }, { "from": "human", "value": "extern crate askama;\nextern crate proc_macro;\nextern crate syn;\n\nuse proc_macro::TokenStream;\n\nfn get_path_from_attrs(attrs: &Vec<syn::Attribute>) -> String {\n for attr in attrs {\n ...
rust
chosen
[ { "from": "system", "value": "Use `compile_error!` instead of `use num_cpus`\n" }, { "from": "human", "value": "#[cfg(doctest)]\nuse num_cpus as _;\n\n#[cfg(test)]\ncompile_error!(\"Miri should not touch me\");\n" }, { "from": "gpt", "value": "#[cfg(doctest)]\ncompile_error!(\"rustdo...
rust
chosen
[ { "from": "system", "value": "Use the new pkgconfig API\n" }, { "from": "human", "value": "#[cfg(feature=\"pkg-config\")]\nextern crate \"pkg-config\" as pkg_config;\n\nfn main() {\n if !build_pkgconfig() {\n println!(\"cargo:rustc-flags=-l SDL2\");\n }\n}\n\n#[cfg(not(feature=\"pkg-c...
rust
chosen
[ { "from": "system", "value": "Add macro_use to allow usages of panic! and sorts\n" }, { "from": "human", "value": "#![crate_name = \"kernel\"]\n#![crate_type = \"staticlib\"]\n#![no_std]\n#![feature(asm, lang_items)]\n#![feature(core)]\n\nextern crate core;\nextern crate rlibc;\n\n#[path = \"arc...
rust
chosen
[ { "from": "system", "value": "Remove unsafe use of unsafe and instead panic\n" }, { "from": "human", "value": "use std::str::{from_utf8_unchecked, FromStr};\n\npub fn to_string(s: &[u8]) -> &str {\n unsafe { from_utf8_unchecked(s) }\n}\npub fn to_u32(s: &str) -> u32 {\n FromStr::from_str(s...
rust
chosen
[ { "from": "system", "value": "Remove Debug implementation for now.\n\nDebugStruct only stabilized in 1.2.0\n" }, { "from": "human", "value": "extern crate encoding;\n\nuse std::fmt;\n\nuse self::encoding::types::EncodingRef;\n\n/// ParseOptions allows setting options for parsing MO catalogs.\npu...
rust
chosen
[ { "from": "system", "value": "Fix parsing JSON containing URLs with escaping\n\nScenario: PHP escapes slashes when encoding JSON. Any escaping in a string\nmeans Serde cannot return a string slice anymore, only an owned string. Our URL\nparsing was relying on deserializing as a string slice.\n" }, { ...
rust
chosen
[ { "from": "system", "value": "Add comment to unsafe use.\n" }, { "from": "human", "value": "// Copyright 2019 The Exonum Team\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy o...
rust
chosen
[ { "from": "system", "value": "Add a newline after pretty printing\n" }, { "from": "human", "value": "extern crate ppbert;\n\nuse std::io;\nuse std::io::Read;\n\nuse ppbert::parser;\nuse ppbert::pretty;\n\nfn main() {\n let mut stdin = io::stdin();\n let mut buf: Vec<u8> = Vec::new();\n\n ...
rust
chosen
[ { "from": "system", "value": "Simplify command parsing; Add input loop\n" }, { "from": "human", "value": "mod diff;\n\nuse std::io;\n\nenum Mode {\n Command,\n Input,\n}\n\nstruct Range {\n start: i32,\n end: i32,\n}\n\n\nfn command_line(line: &String, mode: &mut Mode) {\n match l...
rust
chosen
[ { "from": "system", "value": "Call init_logger after parsing the args.\n" }, { "from": "human", "value": "use std::io::Write;\n\nextern crate watchexec;\n\nuse watchexec::{cli, error, run};\n\nfn main() -> error::Result<()> {\n run(cli::get_args()?)\n}\n\nfn init_logger(debug: bool) {\n le...
rust
chosen
[ { "from": "system", "value": "Add options struct & optionals\n\nWhy you made the change:\n\nI did this so that the code would be a bit cleaner.\n" }, { "from": "human", "value": "extern crate argparse;\n\nuse argparse::{ArgumentParser, StoreTrue, Store, StoreOption, Print};\n\nfn main() {\n l...
rust
chosen
[ { "from": "system", "value": "Add comparision between guess and secret_number\n" }, { "from": "human", "value": "extern crate rand;\n\nuse std::io;\nuse rand::Rng;\n\nfn main() {\n println!(\"Hello in my guessing game!\");\n\n let secret_number = rand::thread_rng().gen_range(1, 101);\n\n ...
rust
chosen
[ { "from": "system", "value": "Use new std::net module in day 9.\n" }, { "from": "human", "value": "#![feature(io)]\n\nextern crate anymap;\n\nuse std::old_io::net::ip::IpAddr;\nuse anymap::AnyMap;\n\n#[derive(Debug)]\nenum HostAddress {\n DomainName(String),\n Ip(IpAddr),\n}\n\n#[derive(De...
rust
chosen
[ { "from": "system", "value": "Remove type annotations that can be inferred\n" }, { "from": "human", "value": "#![allow(unstable)]\n\nextern crate getopts;\nextern crate selecta;\n\nuse getopts::{optopt,getopts};\nuse selecta::configuration::Configuration;\nuse selecta::search::Search;\nuse selec...
rust
chosen
[ { "from": "system", "value": "Clean up the raw module a bit\n" }, { "from": "human", "value": "mod raw {\n extern crate libc;\n\n #[allow(non_camel_case_types)]\n pub type wl_display = libc::c_void;\n\n #[link(name = \"wayland-client\")]\n extern {\n pub fn wl_display_conne...
rust
chosen
[ { "from": "system", "value": "Swap Vec<f64> with [f64, N]\n" }, { "from": "human", "value": "fn schwefel(solution: &Vec<f64>) -> f64 {\n return 418.9829_f64 * solution.len() as f64\n + solution.iter().fold(0_f64, |sum, x| sum + x * x.abs().sqrt().sin());\n}\n\nfn main() {\n println!...
rust
chosen
[ { "from": "system", "value": "Change runtime of REPL to proxy through program\n" }, { "from": "human", "value": "mod vm;\nmod command;\nmod parse;\nmod program;\n\nuse vm::VM;\nuse std::io::Write;\n\nfn main() {\n let mut vm = VM::new();\n loop {\n print!(\"{}\", \"bf> \");\n ...
rust
chosen
[ { "from": "system", "value": "Print nicer error messages for myself\n" }, { "from": "human", "value": "extern crate sassers;\nextern crate docopt;\n\nuse docopt::Docopt;\nuse std::fs::File;\nuse std::io::Read;\nuse std::path::Path;\n\nfn main() {\n const VERSION: &'static str = env!(\"CARGO_P...
rust
chosen
[ { "from": "system", "value": "Add a function for parsing command-line arguments\n" }, { "from": "human", "value": "fn main() {\n println!(\"Hello, world!\")\n}\n" }, { "from": "gpt", "value": "extern crate getopts;\nuse getopts::{optopt, optflag, OptGroup};\nuse std::os;\n\n\nuse ...
rust
chosen
[ { "from": "system", "value": "Make the Key enum printable for debugging\n" }, { "from": "human", "value": "use std::io;\n\npub use self::posix::PosixInputHandler;\n\nmod posix;\n\nconst CMD_PROMPT: &'static str = \">> \";\n\nenum Key {\n Esc,\n Enter,\n Tab,\n\n Up,\n Down,\n L...
rust
chosen
[ { "from": "system", "value": "Fix Option camel case in a compile-fail test\n\nThe compile fails for another reason, that triggers before the the failure for non-camel cased option, some or none undefined errors.\n" }, { "from": "human", "value": "// Copyright 2012 The Rust Project Developers. Se...
rust
chosen
[ { "from": "system", "value": "Change logic of increment and continue branch\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": "Use real array instead of text array to save tags\n" }, { "from": "human", "value": "use storage::file::FileHeaderSpec as FHS;\nuse storage::file::FileHeaderData as FHD;\n\npub fn get_spec() -> FHS {\n FHS::Map { keys: vec![ url_key(), tags_key() ] }\n}\n\nfn url...
rust
chosen
[ { "from": "system", "value": "Remove unused parts of UrlDef\n" }, { "from": "human", "value": "use url::Url;\nuse serde::de::{Deserialize, Deserializer, Error as DeserializeError};\nuse serde::ser::{Serialize, Serializer};\n\n\n/// Type which can be used to serialize a Url.\n///\n/// `#[serde(wi...
rust
chosen
[ { "from": "system", "value": "Add a bunch more property tests\n\nSearching for hex codes, and for control characters.\n" }, { "from": "human", "value": "#[macro_use]\nextern crate proptest;\nextern crate chars;\n\nuse chars::human_names;\n\nuse proptest::prelude::*;\nuse proptest::test_runner::C...
rust
chosen
[ { "from": "system", "value": "Remove unused variable from Alphametics stub\n" }, { "from": "human", "value": "use std::collections::HashMap;\n\npub fn solve(puzzle: &str) -> Option<HashMap<char, u8>> {\n unimplemented!()\n}\n" }, { "from": "gpt", "value": "use std::collections::Ha...
rust
chosen
[ { "from": "system", "value": "Add license to stable check\n\nso that this passes tidy on rust master\n" }, { "from": "human", "value": "use std::error::Error;\nuse std::env;\nuse std::fs;\nuse std::fs::File;\nuse std::io::prelude::*;\nuse std::path::Path;\n\nfn main() {\n let arg = env::args(...
rust
chosen
[ { "from": "system", "value": "Return PathBuf instead of &Path\n" }, { "from": "human", "value": "// Here lists all the paths that will be used by wiz\nuse std::path::{ Path, PathBuf };\n\n///\n/// Appends `append` to `path`.\n///\npub trait PathAppend {\n fn append(&mut self, input: &str) -> ...
rust
chosen
[ { "from": "system", "value": "Implement BlasVector on Vec and slice\n" }, { "from": "human", "value": "// Copyright 2014 Michael Yang. All rights reserved.\n// Use of this source code is governed by a MIT-style\n// license that can be found in the LICENSE file.\n\npub mod ll;\npub mod ops;\n\npu...
rust
chosen
[ { "from": "system", "value": "Use automatic dereference in benchmark\n" }, { "from": "human", "value": "#[macro_use]\nextern crate perl_xs;\n#[macro_use]\nextern crate perl_sys;\n\nuse perl_xs::{ SV, AV, IV, NV };\n\nxs! {\n package XSBench::RS;\n \n sub rs_sum_loop(ctx, param: SV) {\n ...
rust
chosen
[ { "from": "system", "value": "Remove current directory from begginnig of displayed paths\n" }, { "from": "human", "value": "// Copyright (C) 2016 Élisabeth HENRY.\n//\n// This file is part of Crowbook.\n//\n// Crowbook is free software: you can redistribute it and/or modify\n// it under the term...
rust
chosen
[ { "from": "system", "value": "Enable static linking support (similar to openssl-sys)\n" }, { "from": "human", "value": "fn main () {\n println!(\"cargo:rustc-flags=-l sodium\");\n}\n" }, { "from": "gpt", "value": "use std::env;\n\nfn main () {\n if let Some(lib_dir) = env::var(...
rust
chosen
[ { "from": "system", "value": "Add tests for all heading levels\n" }, { "from": "human", "value": "use super::builder::Builder;\nuse ast::HeadingLevel;\n\n///\n/// HTML generation might need to be customized to invividual use.\n/// A `Format` allows to customize output generation (e.g. custom tag...
rust
chosen
[ { "from": "system", "value": "Update mini-macro post proc macro stabilization\n\nhttps://github.com/rust-lang/rust/pull/52081 stabilized proc macros, but\nquote is still unstable, so you need to explicitly enable that feature.\n" }, { "from": "human", "value": "#![feature(proc_macro, proc_macro_...
rust
chosen
[ { "from": "system", "value": "Test where the old infrastructure failed to detect the (applicable) impl of `FnMut` for\nsome reason.\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\...
rust
chosen
[ { "from": "system", "value": "Add documentation for own Result type\n" }, { "from": "human", "value": "//! Module containing `Result` type\n\nuse std::result::Result as RResult;\n\nuse error::TaskError;\n\npub type Result<T> = RResult<T, TaskError>;\n" }, { "from": "gpt", "value": "/...
rust
chosen
[ { "from": "system", "value": "Rename JsStr to JsStrStruct, among other things\n" }, { "from": "human", "value": "use std::string::String;\nuse std::vec::Vec;\nuse js_types::js_type::{JsTrait, JsT};\n\n// `undefined`\npub struct JsUndef;\nimpl JsTrait for JsUndef {}\n\n// `null`\npub struct JsNul...
rust
chosen
[ { "from": "system", "value": "Remove locking around log! statements\n" }, { "from": "human", "value": "use ::arch::debug;\nuse core::fmt::{Error,Write};\nuse spin::{MutexGuard,StaticMutex,STATIC_MUTEX_INIT};\n\npub struct Writer<'a> {\n _state: MutexGuard<'a, ()>\n}\n\nstatic LOGGING_LOCK: St...
rust
chosen
[ { "from": "system", "value": "Fix error message in compile-fail test\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// Licensed under the ...
rust
chosen
[ { "from": "system", "value": "Fix compile on riscv again\n" }, { "from": "human", "value": "intrinsics! {\n // Implementation from gcc\n // https://raw.githubusercontent.com/gcc-mirror/gcc/master/libgcc/config/epiphany/mulsi3.c\n pub extern \"C\" fn __mulsi3(a: u32, b: u32) -> u32 {\n ...
rust
chosen
[ { "from": "system", "value": "Remove unused parameter from Actor::kill()\n" }, { "from": "human", "value": "use util::units::Point;\n\npub struct Actor {\n name: String,\n pos: Point,\n health: int,\n max_health: int,\n repr: char,\n}\n\nimpl Actor {\n\n pub fn new(name: String...
rust
chosen
[ { "from": "system", "value": "Use map_or to simplify code\n\nIt looks better\n" }, { "from": "human", "value": "use std::collections::HashMap;\n\nfn anagrams(word: &str) -> HashMap<char, u32> {\n let mut result: HashMap<char, u32> = HashMap::new();\n\n for k in word.chars() {\n let ...
rust
chosen
[ { "from": "system", "value": "Add ucontext and clone_args for loongarch64\n" }, { "from": "human", "value": "s_no_extra_traits! {\n #[allow(missing_debug_implementations)]\n #[repr(align(16))]\n pub struct max_align_t {\n priv_: [f64; 4]\n }\n}\n" }, { "from": "gpt", ...
rust
chosen
[ { "from": "system", "value": "Add ordering constraints to Alphabet. Add make_{non}terminal to DualAlphabet\n" }, { "from": "human", "value": "extern crate expression;\n#[cfg(test)]\nextern crate expression_num;\n\npub mod parametric;\n\nuse std::fmt::Debug;\n\n/// Used to name symbols and variab...
rust
chosen
[ { "from": "system", "value": "Fix parsing empty C string.\n" }, { "from": "human", "value": "extern crate libc;\n\nuse self::libc::c_char;\n\nuse std::ffi::CStr;\nuse std::str::Utf8Error;\nuse std::ffi::CString;\n\npub struct CStringUtils {}\n\nimpl CStringUtils {\n pub fn c_str_to_string(cst...
rust
chosen
[ { "from": "system", "value": "Add some logs to test the key pressed event\n" }, { "from": "human", "value": "use nain_events::{EventCategory, KeyPressedEvent};\nuse nain_log as log;\n\npub trait Application {\n fn run(&self) {\n println!(\"Welcome to the Nain engine!\");\n\n let...
rust
chosen
[ { "from": "system", "value": "Build patterns in OUT_DIR only\n" }, { "from": "human", "value": "extern crate glob;\n\nuse glob::glob;\nuse std::fs::File;\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::fmt;\n\nfn main() {\n let mut output = String::new();\n\n fmt::write(\n ...
rust
chosen
[ { "from": "system", "value": "Use env::arg instead of env macro\n" }, { "from": "human", "value": "extern crate crowbook_localize;\nuse crowbook_localize::{Localizer, Extractor};\n\nuse std::path::Path;\n\nfn main() {\n println!(\"cargo:rerun-if-changed=build.rs\");\n println!(\"cargo:reru...
rust
chosen
[ { "from": "system", "value": "Add 'Series' to supported metadata\n" }, { "from": "human", "value": "use chrono::{DateTime, FixedOffset};\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\npub(super) struct Page {\n title: Option<String>,\n subtitle: Option<String>,\n summary: Op...
rust
chosen
[ { "from": "system", "value": "Rename method of Spanned to avoid conflict with syn Spanned\n" }, { "from": "human", "value": "use crate::ToTokens;\nuse proc_macro2::{Span, TokenStream};\n\npub trait Spanned {\n fn span(&self) -> Span;\n}\n\nimpl Spanned for Span {\n fn span(&self) -> Span {...
rust
chosen
[ { "from": "system", "value": "Fix deprecation by deriving from Debug rather than Show.\n" }, { "from": "human", "value": "#[derive(PartialEq, Show)]\npub enum Category {\n Whitespace,\n Identifier,\n Brace,\n Parenthesis,\n AssignmentOperator,\n IntegerLiteral,\n StringLiter...
rust
chosen
[ { "from": "system", "value": "Add test which uses assert!\n" }, { "from": "human", "value": "#[derive(Debug)]\npub struct Rectangle {\n length: u32,\n width: u32\n}\n\nimpl Rectangle {\n pub fn can_hold(&self, other: &Rectangle) -> bool {\n self.length > other.length && self.widt...
rust
chosen
[ { "from": "system", "value": "stdlib: Modify union-find to guarantee that root nodes are always less than or equal to leaf nodes; add a \"prune\" method\n" }, { "from": "human", "value": "import option::none;\nimport option::some;\n\n// A very naive implementation of union-find with unsigned int...
rust
chosen
[ { "from": "system", "value": "Build script tweak: using Path::display() correctly now.\n" }, { "from": "human", "value": "use std::process::Command;\n\nextern crate pkg_config;\n\nconst C_IN: &'static str = \"include/include_ffi.h\";\nconst RS_OUT: &'static str = \"src/raw.rs\";\n\nfn main() {...
rust
chosen
[ { "from": "system", "value": "Fix typo ('commited', needs 2nd 't')\n\nJust fixing a small typo in examples/transactions.rs. (The word \"committed\" should have a double-m a double-t. Right now, this code misspells it with just one t.)" }, { "from": "human", "value": "// Copyright 2015, Igor Sha...
rust
chosen
[ { "from": "system", "value": "Fix use of sleep function after api change\n" }, { "from": "human", "value": "// Implements http://rosettacode.org/wiki/Concurrent_computing\n// not_tested\nuse std::io::timer::sleep;\nuse std::rand::random;\n\nfn main() {\n let strings = vec![\"Enjoy\", \"Rosett...
rust
chosen
[ { "from": "system", "value": "Fix syntax for non-doc comments, and use `crate::` instead of `std::`.\n" }, { "from": "human", "value": "use std::mem::size_of;\nuse std::os::wasi::io::RawFd;\n\n#[test]\nfn test_raw_fd_layout() {\n /// `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_r...
rust
chosen
[ { "from": "system", "value": "Refactor tokenize to use str::words\n" }, { "from": "human", "value": "extern mod std;\n\n#[test]\nfn test_tokenize() {\n assert tokenize( ~\"(1 2 3)\" ) == ~[~\"(\", ~\"1\", ~\"2\", ~\"3\", ~\")\"];\n}\n\n#[test]\nfn test_tokenize_empty() {\n assert tokenize(...
rust
chosen
[ { "from": "system", "value": "Use ast.generics.split_for_impl() to correctly generate impl with any generic parameters\n" }, { "from": "human", "value": "#![feature(proc_macro)]\n#![feature(proc_macro_lib)]\n#![recursion_limit = \"128\"]\n\n#[macro_use] extern crate quote;\n\nextern crate proc_m...
rust
chosen
[ { "from": "system", "value": "Add spec links for xul properties\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://mozilla.org/MPL...
rust
chosen
[ { "from": "system", "value": "Test is_scalar/is_array/is_compound for scalar types\n" }, { "from": "human", "value": "#[macro_use]\nextern crate pod_typeinfo;\n\nuse std::mem;\n\nuse pod_typeinfo::Type::*;\nuse pod_typeinfo::{Type, TypeInfo};\n\n#[test]\nfn test_scalar_types() {\n fn check_ty...
rust
chosen
[ { "from": "system", "value": "Add single listing to issue example.\n" }, { "from": "human", "value": "\nextern crate gitlab_api as gitlab;\n\nuse std::env;\n#[macro_use]\nextern crate log;\nextern crate env_logger;\n\nuse gitlab::GitLab;\n// use gitlab::Pagination;\nuse gitlab::issues;\n\n\nfn m...
rust
chosen
[ { "from": "system", "value": "Add extra compile fail error\n" }, { "from": "human", "value": "#[macro_use]\nextern crate diesel;\n\nuse diesel::*;\n\ntable! {\n int_primary_key {\n id -> Serial,\n }\n}\n\ntable! {\n string_primary_key {\n id -> VarChar,\n }\n}\n\nfn mai...
rust
chosen